3NF范式
我有一个关于 3NF 范式的问题:
Normalize, with respect to 3NF, the relational scheme E(A, B, C, D, E, F)
by assuming that (A, B, C) is the unique candidate key and that the following additional functional dependencies hold:
A,B -> D
C,D -> E
E -> F
则模式是 3NF
我的理解是,如果我应用 3NF,即如果所有非素数属性不传递依赖于任何关键候选,
,结果应该是: E'=(A ,B,C,E,F), E''= (B,D) , E'''= A,B,C,D,F) , E''''=(D,E) , E''''''= (A,B,C,D,E),
E''''''= (E,F)
但我确实认为我错了......
有人可以帮助理解这个问题吗?
谢谢
I have a question about 3NF normal form:
Normalize, with respect to 3NF, the relational scheme E(A, B, C, D, E, F)
by assuming that (A, B, C) is the unique candidate key and that the following additional functional dependencies hold:
A,B -> D
C,D -> E
E -> F
My understanding is that if I apply the 3NF which says that a schema is 3NF if all attributes
non-prime do not transitively depend on any key candidate , the result should be:
E'=(A,B,C,E,F), E''= (B,D) , E'''= A,B,C,D,F) , E''''=(D,E) , E''''''= (A,B,C,D,E),
E''''''= (E,F)
but I do think I'm wrong...
Can someone help understand the issue?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(为了可读性而重新格式化)
3NF 表示 a) 关系属于 2NF,并且 b) 每个非素数属性都直接依赖于(即,不传递依赖于)每个 候选键。
反过来,2NF 意味着 a) 关系属于 1NF,并且 b) 每个非素数属性都依赖于每个候选键的整体,而不仅仅是任何候选键的一部分。
给定 {ABC} 是候选键,并且给定 {AB->D},您可以看到 D 取决于候选键的一部分。所以
不在 2NF 中。您可以通过将该依赖属性移至新关系来修复此问题,然后将确定它的属性复制到同一关系。
R0 = {ABC DEF} 这种关系(我们一开始的关系不在 2NF 中)消失了,取而代之的是
R 取代1 = {ABC EF}
您想从这里继续吗?
(Reformatted for readability)
3NF means that a) the relation is in 2NF, and b) every non-prime attribute is directly dependent (that is, not transitively dependent) on every candidate key.
In turn, 2NF means that a) the relation is in 1NF, and b) every non-prime attribute is dependent on the whole of every candidate key, not just on part of any candidate key.
Given {ABC} is a candidate key, and given {AB->D}, you can see that D depends on part of a candidate key. So
is not in 2NF. You fix that by moving that dependent attribute to a new relation, and you copy the attributes that determine it to the same relation.
R0 = {ABC DEF} This relation—which we started with, and which is not in 2NF—goes away, to be replaced with
R1 = {ABC EF}
You want to continue from here?
当谈到正确标准化时,没有什么可以替代理解正式定义。如果您仍在努力建立这种理解,那么人们可以使用一个可爱的小助记符来帮助记住 3NF 的本质并判断他们正在查看的表是否是 3NF。
你如何应用它?关系的每个属性都必须依赖于键。它必须依赖于整个密钥。我不能依赖任何不是关键的东西。当您查看示例时,显然存在问题,您需要正常化。您需要达到这样的程度:每个违反 3NF 的非键列都脱离了您的原始关系。每个非键列 D、E 和 F 都违反 3NF。
请注意,您的附加功能依赖项涵盖原始关系中的所有非键列。这些附加函数依赖项中的每一个都会产生一个关系:
{ A B D } - 这解决了属性 D
的 3NF
{ C D E } - 这解决了属性 E 的 3NF
{ E F } - 这解决了属性 F 的 3NF
您的原始关系还剩下什么?除了候选键之外什么都没有:
{ AB C }
When it comes to getting normalization right, there is no substitute for understanding the formal definitions. If you're still working on building that understanding, there's a cute little mnemonic that people use to help remember the essence of 3NF and to judge whether a table that they're looking at is 3NF or not.
How do you apply it? Every attribute of the relation must depend on the key. It must depend on the whole key. I must not depend on anything that isn't the key. When you look at your example, clearly there are problems and you need to normalize. You need to get to a point where every non-key column which violates 3NF is out of your original relation. Each of the non-key columns, D, E, and F all violate 3NF.
Note that your additional functional dependencies cover all of the non-key columns in your original relation. Each of these additional functional dependencies is going to result in a relation:
{ A B D } - This solves 3NF for attribute D
{ C D E } - This solves 3NF for attribute E
{ E F } - This solves 3NF for attribute F
What is left to cover from your original relation? Nothing except the candidate key:
{ A B C }