Is it true that a database is 2NF by default if th

2019-07-14 14:06发布

问题:

i.e. there is a table with only 1 primary key (no composite keys). Is it 2NF by default? Assume that it is already 1NF

回答1:

http://en.wikipedia.org/wiki/Second_normal_form

in your example, PatNo is not a primary key since PatNo may see more than one doctor, or have more than one appNo.



回答2:

Loosely speaking, a table is in 2NF if and only if it's

  • in 1NF, and
  • there are no partial key dependencies.

That's not quite the same thing as saying a table that has a single-column primary key is in 2NF. A table like this

person_id  full_name       phones
--
-43        Ericka Cimini   555-222-1515
                           555-232-6100
-18        Julio Martina   555-123-4567

has a single-column primary key ("person_id"), but it isn't in 1NF. (See wikipedia for details.) And since it's not in 1NF, it can't possibly be in 2NF.



回答3:

I think got it now.

In my example if there is more than 1 doctor, then doctor is also partially dependent on the patient number because the doctor has to see the correct patient. It's just confusing because doctor is also transitively dependent to patNo via appNo.



回答4:

Maybe this late response might be helpful to others. We were taught (perhaps mistakenly) that irrelevant data also fell under 2NF. So animal(phylum, class, order, family, genus, species, greek_phoneme) would not be in 2NF because Greek phonemes have nothing to do with Animals.