数据库和第二范式

发布于 2024-11-16 19:02:57 字数 430 浏览 1 评论 0原文

我有一个满足以下关系的表:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

折戟 2024-11-23 19:02:57

当且仅当所有非素数属性在功能上依赖于每个候选键的所有属性,而不仅仅是依赖于任何候选键的属性子集时,表才处于 2nf 状态。

根据您的评论,您将获得两个键:{ABC} 和 {DE}。

在{AB}->{HI}的情况下,属性H和I依赖于密钥的一部分。 ({AB} 是键 {ABC} 的一部分。)因此,您从 R 投影 {HI} 是正确的。对于 {D}->{FG} 和 {E}->{MN},同上。

  • R1 = {ABCDEJKL}
  • R2 = {ABHI}
  • R3 = {DFG}
  • R4 = { EMN}

当涉及到属性 J、K 和 L 时,您必须问同样的问题。

  • J 在功能上是否依赖于属性 A、B、C、D 和 E 的任意组合(不包括给定键 {ABC} 和 {DE})?
  • K 在功能上是否依赖于属性 A、B、C、D 和 E 的任意组合(不包括给定键 {ABC} 和 {DE})?
  • L 在功能上是否依赖于属性 A、B、C、D 和 E 的任意组合(不包括给定键 {ABC} 和 {DE})?

您对 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}.

  • R1 = {ABCDEJKL}
  • R2 = {ABHI}
  • R3 = {DFG}
  • R4 = {EMN}

When it comes to the attributes J, K, and L, you have to ask the same question.

  • Is J functionally dependent on any combination of the attributes A, B, C, D, and E, excluding the given keys {ABC} and {DE}?
  • Is K functionally dependent on any combination of the attributes A, B, C, D, and E, excluding the given keys {ABC} and {DE}?
  • Is L functionally dependent on any combination of the attributes A, B, C, D, and E, excluding the given keys {ABC} and {DE}?

What do you think about J, K, and L?

娇女薄笑 2024-11-23 19:02:57

根据你的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}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文