这个表是2NF吗?
在尝试了解数据库规范化时,我对下表感到困惑:
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
我正在使用的书将此作为 1NF 中的表的示例。然而,在阅读了维基百科上关于 1NF、2NF 和 3NF 的文章后,我有点困惑。
据我所知,该表有两个候选键:{Name,Organisms} 和 {Date,Organisms}。根据维基百科(链接文本):
当且仅当其所有非素数属性在功能上依赖于每个候选键的整体时,1NF 表才是 2NF。 (非主要属性是不属于任何候选键的属性。)
根据“非主要属性”的定义,在我看来,该表没有非主要属性,因为每个字段至少属于两个候选键之一。如果没有非素数属性,那么(因为该表位于 1NF 中)根据维基百科的定义,该表似乎位于 2NF 中。
然而,我认识到这个表设计得很糟糕,而且容易出现更新错误,所以我想我一定在某个地方犯了逻辑错误。 如果有人可以解释该表采用哪种范式和/或我的推理哪里有错误,我将不胜感激。
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, after 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正确地认为不存在非素数属性,那么所讨论的关系将至少为 2NF。然而,仅根据一组属性名称来猜测可能应用哪些键和依赖项始终是一项高度主观的练习。只有当您定义了应该满足哪些依赖关系时,这样的示例才真正有用。
我建议您不要依赖在维基百科中阅读的任何内容。这不是一个好的教育工具。找一本关于这个主题的好书,比如克里斯·戴特(Chris Date)或大卫·迈尔(David Maier)写的书。
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.