开发者

Is this table in 2NF?

开发者 https://www.devze.com 2023-01-26 12:39 出处:网络
In trying to learn about database normalization, I am confused by the following table: NameDateOrganisms

In trying to learn about database normalization, I am confused by the following table:

Name      Date          Organisms
aging     1984-07-13    human
aging     1984-07-13    worm
wrinkle   1987-08-15    human
wrinkle   1987-08-15    mouse
hairy     1990-09-30    mouse

The book I am using presents this as an example of a table in 1NF. However, a开发者_运维问答fter reading the Wikipedia articles on 1NF, 2NF, and 3NF, I'm a bit confused.

As far as I can tell, this table has two candidate keys: {Name,Organisms} and {Date,Organisms}. According to Wikipedia (link text):

A 1NF table is in 2NF if and only if all its non-prime attributes are functionally dependent on the whole of every candidate key. (A non-prime attribute is one that does not belong to any candidate key.)

By this definition for "non-prime attribute", it seems to me that this table has no non-prime attributes because every field belongs to at least one of the two candidate keys. If there are no non-prime attributes, then (since this table is in 1NF) it seems this table is in 2NF by the Wikipedia definition.

However, I recognize that this table is poorly designed and prone to update errors, so I think I must be making an error in logic somewhere. If someone could explain which normal form this table is in and/or where my reasoning is faulty, I would greatly appreciate it.


If you are correct that there are no nonprime attributes then the relation in question would be in at least 2NF. However, guessing at what keys and dependencies may apply based only on a set of attribute names is always going to be a highly subjective exercise. Examples like this are really only useful if you define what dependencies are supposed to be satisfied.

I recommend you don't rely on anything you read in Wikipedia. It's not a good educational tool. Get a decent book on the subject, such as those by Chris Date or David Maier.

0

精彩评论

暂无评论...
验证码 换一张
取 消