关于关系规范化的问题
例如,让我们考虑以下关系:
R(A、B、C、D、E、F)
其中粗体表示它是主键属性
F = {AB->DE, D->E}
现在,这看起来是第一范式。它不能采用第三范式,因为我有传递依赖性,并且它不能采用第二种形式,因为并非所有非键属性都依赖于整个主键。
所以我的问题是:
我不知道 F 和 C 是什么。我没有关于它们的任何功能依赖信息! F 不依赖于任何东西?如果是这样的话,我想不出任何解决方案可以让 R 进入第二范式而不将其取出!
C呢? C 还存在未在函数依赖列表中引用的问题。该怎么办?
我尝试将 R 转化为第二范式,类似于:
R(A,B,D)
R' (D,E)
但如前所述,我不知道如何处理 C 和 F。它们是否多余,所以我只需将它们取出,上面的尝试就是我所要做的将其变成第二种形式(和第三种!)?
谢谢
Let's consider, for instance, the following relation:
R (A,B,C,D,E,F)
where the bold denotes that it is a primary key attribute
with
F = {AB->DE, D->E}
Now, this looks to be in the first normal form. It can't be on the third normal form as I have a transitive dependency and it cannot be in the second form as not all non-key attributes depend on the whole primary key.
So my questions are:
I don't know what to make of F and C. I don't have any functional dependency info on them! F doesn't depend on anything? If that is the case, I can't think of any solution to get R into the 2nd normal form without taking it out!
What about C? C also suffers from the problem of not being referred on the functional dependencies list. What to do about it?
My attempt to get R into the 2nd normal form would be something like:
R(A,B,D)
R' (D,E)
but as stated earlier, I don't have a clue of what to do of C and F. Are they redundant so I simply take them out and the above attempt is all I have to do to get it into the 2nd form (and 3rd!)?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
给定 R 的定义,{ A, B, C } 是主键,那么本质上存在函数依赖性:
这表示 A、B 和 C 的值本质上决定或控制 D、E 的值和 F 以及他们决定自己的价值观这一琐碎的事实。
您还有一些额外的依赖项,由集合 F 标识(与属性 F 不同 - 该表示法不太恰当,可能会导致混乱*):
As你的诊断是正确的,系统处于 1NF 状态(因为 1NF 的真正意思是“它是一张桌子”)。由于传递依赖并且某些属性仅依赖于键的一部分,因此它不在 2NF 或 3NF 或 BCNF 等中。
你是对的,作为分解的一部分,你最终会得到以下两个关系:
您还需要第三个关系:
通过这些,您可以使用连接重新创建原始关系 R。关系集 { R1, R2, R3 } 是原始关系 R 的无损分解。
* 如果标识辅助功能依赖集的 F 旨在与属性 F 相同,那么该属性的定义就会非常奇怪。我需要查看关系 R 的示例数据,才有机会知道如何解释它。
Given the definition of R that { A, B, C } is the primary key, then there is inherently a functional dependency:
That says that the values of A, B and C inherently determine or control the values of D, E and F as well as the trivial fact that they determine their own values.
You have a few additional dependencies, identified by the set F (which is distinct from the attribute F - the notation is not very felicitous, and could be causing confusion*):
As you rightly diagnose, the system is in 1NF (because 1NF really means "it is a table"). It is not in 2NF or 3NF or BCNF etc because of the transitive dependency and because some of the attributes only depend on part of the key.
You are right that you will end up with the following two relations as part of your decomposition:
You also need the third relation:
From these, you can recreate the original relation R using joins. The set of relations { R1, R2, R3 } is a non-loss decomposition of the original relation R.
* If the F identifying the set of subsidiary functional dependencies is intended to be the same as the attribute F, then there is something very weird about the definition of that attribute. I'd need to see sample data for the relation R to have a chance of knowing how to interpret it.
我认为R的主键设置错误。如果 F 在功能上与任何东西都不相关它必须是键的一部分
所以你有 R( ABCF DE) 它现在是第一范式(与F = {AB->DE, D->E}) 现在您可以将其更改为第二范式。 DE 不依赖于整个密钥(部分依赖),因此您将其放入另一个关系中以获得第二范式:
R( ABCF ) F = {}
R1( #AB< /strong> DE) F = {AB->DE}
现在这个关系没有任何传递依赖,所以它已经是第三范式了。
I think the primary key of R is set wrong. If F isn't functionally related to anything it has to be a part of the key
So you have R( ABCF DE) which is now in the first normal form (with F = {AB->DE, D->E}) Now you can change it to the second normal form. DE isn't dependant on the whole key (partial dependency) so you put it in another relation to get to second normal form:
R( ABCF ) F = {}
R1( #AB DE) F = {AB->DE}
Now this relation doesn't have any transitive dependencies so it is already in third normal form.
不,您只是没有在形式中获得任何关于它的明确信息
,对于 C 来说基本上也是如此。您需要通过应用阿姆斯特朗公理来推断其他依赖关系。 (可能吧。)
想想如何完成这个:
给定 R (A,B,C,D,E,F)
[之后 。 。 。我看到乔纳森·莱夫勒打破了悬念,所以我就结束这个。]
{ABC -> DEF}(根据定义)因此,
{ABC -> F} (通过分解。这就是 F 和 C 出现的地方。这是你的第三个关系。)。
No, you just haven't been given any explicit information about it in the form
And essentially the same can be said for C. You're expected to infer the other dependencies by applying Armstrong's axioms. (Probably.)
Think about how to finish this:
Given R (A,B,C,D,E,F)
[Later . . . I see that Jonathan Leffler has broken the suspense, so I'll just finish this.]
{ABC -> DEF} (By definition) therefore,
{ABC -> F} (By decomposition. Here's where F and C come in. And this is your third relation. ).