数据库和第二范式
我有一个满足以下关系的表:
R(A, B, C, D, E, F, G, H, I, J, K, L, M, N)
{A, B, C} is the primary key.
{D, E} forms a candidate key.
The following functional dependencies exist among the attributes of the relation:
{A, B} -> {H,I}
{D} -> {F,G}
{J} -> {K,L}
{E} -> {M,N}
我需要将其分解为第二范式,因此我将 {AB->HI}, {D->FG}, {E->MN} 分开
到独立的表中。但是 {J->KL}
怎么样?我应该如何规范化这个?
I have a table that satisfies the following relations:
R(A, B, C, D, E, F, G, H, I, J, K, L, M, N)
{A, B, C} is the primary key.
{D, E} forms a candidate key.
The following functional dependencies exist among the attributes of the relation:
{A, B} -> {H,I}
{D} -> {F,G}
{J} -> {K,L}
{E} -> {M,N}
I need to decompose this to the 2nd normal form, so I separate {AB->HI}, {D->FG}, {E->MN}
into independent tables. But how about {J->KL}
? How should I normalize this one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当且仅当所有非素数属性在功能上依赖于每个候选键的所有属性,而不仅仅是依赖于任何候选键的属性子集时,表才处于 2nf 状态。
根据您的评论,您将获得两个键:{ABC} 和 {DE}。
在{AB}->{HI}的情况下,属性H和I依赖于密钥的一部分。 ({AB} 是键 {ABC} 的一部分。)因此,您从 R 投影 {HI} 是正确的。对于 {D}->{FG} 和 {E}->{MN},同上。
当涉及到属性 J、K 和 L 时,您必须问同样的问题。
您对 J、K、L 有何看法?
A table is in 2nf if and only if all nonprime attributes are functionally dependent on all the attributes of every candidate key, not just on a subset of attributes of any candidate key.
According to your comment, you're given two keys, {ABC} and {DE}.
In the case of {AB}->{HI}, the attributes H and I are dependent on part of a key. ({AB} is part of the key {ABC}.) So you're correct in projecting {HI} from R. Ditto for {D}->{FG} and {E}->{MN}.
When it comes to the attributes J, K, and L, you have to ask the same question.
What do you think about J, K, and L?
根据你的FD:
我认为你在这里选择的PK/CK不好。
只有 CK / PK ={ABCDEJ} 因为 {ABCDEJ} 的闭包 ={ABCDEFGHILKLMN} 所有属性,因此素数属性 (6)={A,B,C,D,E,J}
在 2NF 中,我们不允许部分依赖。
这里是部分功能依赖:
{A,B}-> {H,I} {D} -> {F,G} {J} -> {K,L} {E} -> {M,N}
因此,删除这些部分依赖项后,您的表将像这样分解(删除 2NF 中的部分依赖):
R1 = {ABHI}
R2 = {DFG}
R3 = {JKL}
R4 = {EMN}
R5 = {ABCDEJ}
According to your FD's :
I think your selection of PK/CK is not good here.
Only CK / PK would be ={ABCDEJ} Because closure of {ABCDEJ} ={ABCDEFGHILKLMN}All Attributes , Hence Prime attributes (6)={A,B,C,D,E,J}
In 2NF , we don't allow partial dependencies.
Here Partial Functional Dependencies:
{A, B} -> {H,I} {D} -> {F,G} {J} -> {K,L} {E} -> {M,N}
So after removing these Partial Dependencies your table will be decomposed like this(Removal of Partial Dependency in 2NF):
R1 = {ABHI}
R2 = {DFG}
R3 = {JKL}
R4 = {EMN}
R5 = {ABCDEJ}