数据库无关属性和分解
我对无关属性和正确分解为 3NF 的概念有点困惑。
例如,我有以下关系:
r(A,B,C,D,E,F)
F = FD's
F = {A-> BCD, BC-> DE, B->D, D->A}
我想计算规范覆盖,以便使用算法将其分解为 3NF。所以我必须从 FD 中删除无关的属性。
我计算出A+。 B+、C+、D+(A+ = ABCDE、B+ = BD、C+ = C、D+ = AD)
我开始尝试寻找无关的属性。首先我查看了 β 中的属性
,我试图找出 D 是否与
公元前->德
并使用 BC+ 我发现 D 是无关的(因为 BC+ 包含属性 D)。 所以现在我的 FD 从 BC -> 更改为DE 至 BC -> E
现在我尝试计算 α 的无关属性。
我查看了 FD BC -> 中 B 或 C 是否无关。 DE(计算 B+ 和 C+ 使我发现 B 或 C 都不是无关紧要的,因为它们都不包含 E)。
我还查看了 A -> 中的无关属性BCD 并发现 B 和 C 都是无关的(因为 A+ 包含所有属性)。所以我留下了以下内容:
A -> D
BC -> E
B -> D
D -> A
抱歉,这个问题太长了,我只是想写下我所做的事情。
我很困惑这是否正确,或者我是否正确地这样做了。我正在尝试遵循一些注释和一些在线参考资料,但如果有人能指出我是否做得正确,或者尝试解释一些如何正确找到无关属性和分解,那就太好了。
I am kind of confused on the notion of extraneous attributes and a proper decomposition into 3NF.
For example, I have the following relation:
r(A,B,C,D,E,F)
F = FD's
F = {A-> BCD, BC-> DE, B->D, D->A}
I want to compute the canonical cover in order to decompose it into 3NF using an algorithm. So I have to remove extraneous attributes from the FD's.
I computed A+. B+, C+, D+ (A+ = ABCDE, B+ = BD, C+ = C, D+ = AD)
I started trying to find extraneous attributes. First I looked at attributes in β
I tried to find if D is extraneous in
BC -> DE
and using BC+ I found D is extraneous (Since BC+ contains the attribute D).
So now my FD changed from BC -> DE to BC -> E
Now I tried to compute extraneous attributes for α.
I looked to see if B or C is extraneous in FD BC -> DE
(Computing B+ and C+ led me to neither B or C being extraneous since none of them contain E).
I also looked at extraneous attributed in A -> BCD and found both B and C to be extraneous (Since A+ contains all attributes). So I was left with following:
A -> D
BC -> E
B -> D
D -> A
Sorry for the extremely long question, I just wanted to write down what I did.
I am confused as to if this is correct or if I am even doing this correctly. I am trying to follow some notes and some online references but it would be nice if someone could point out if I am doing this right and if not try and explain somewhat as to properly find extraneous attributes and decomposing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的一些闭包是错误的(B+=ABCDE,例如由于B->D,D->A,A->BCD,BC->DE)。
在A→BCD中B和C不是无关的。事实上,A 的闭包关于
是 AD 而不是 ABCDE。
那么让我们回溯到之前的步骤:
D在A→BCD中是无关的,因为A→B和B→D。我们从A->中消除D。 BCD并得到:
C在BC→E中是无关的。事实上,B->D,D->A,A->A。公元前。因此,
接下来我们将左侧相同的所有 fd 组合起来:
这组函数依赖项不包含冗余依赖项或无关属性,因此是规范覆盖。
Some of your closures are wrong (B+ = ABCDE, for instance due to B->D,D->A,A->BCD,BC->DE).
B and C are not extraneous in A->BCD. Indeed, the closure of A with respect to
is AD rather than ABCDE.
So let us backtrack to your previous step:
D is extraneous in A->BCD since A->B and B->D. We eliminate D from A-> BCD and obtain:
C is extraneous in BC->E. Indeed, B->D, D->A, A-> BC. Hence,
Next we combine all fds with the same left-hand side:
This set of functional dependencies does not contain redundant dependencies or extraneous attributes, and, hence, is a canonical cover.