简体   繁体   English

在3NF中找到关系但在BCNF中找不到关系

[英]Finding a relation in 3NF but not in BCNF

I've been reading many different sources on how to differentiate relations that are in 3NF/BCNF. 我一直在阅读许多关于如何区分3NF / BCNF关系的不同来源。 And I've so far this is my understanding... 到目前为止,这是我的理解......

I will use this relation as an example... 我将以此关系为例......

R = {A, B, C, D, E}

and

F = {A -> B, BC - > E, ED -> A} . F = {A -> B, BC - > E, ED -> A}

Firstly we must find the keys of the relation. 首先,我们必须找到关系的关键。 I used this video to help me do that. 我用这个视频来帮助我做到这一点。 And I got 我得到了

Keys = {ACD, BCD, CDE}

Now to make sure R is in BCNF , we must make sure that the left hand side of every functional dependency in F is one of the Keys . 现在为了确保RBCNF中 ,我们必须确保F中每个功能依赖的左侧是其中一个Keys We instantly know this is not the case, because the first FD is A -> B and A is not one of the keys. 我们立即知道情况并非如此,因为第一个FD是A -> BA不是其中一个键。 So it is not in BCNF. 所以它不在BCNF。

Now to make sure R is in 3NF , we must make sure that the left hand side of every functional dependency in F is one of the Keys OR the right hand side of every functional dependency in F is a subset of one of the Keys . 现在,以确保R3NF,我们必须确保在每一个函数依赖的左边F是一个Keys 每一个函数依赖的右边F是一个子集Keys If you look at the right hand side of every FD, they are B , E and A . 如果你看看每个FD的右侧,它们是BEA These are each a subset of a Key , so this means that it is in 3NF . 这些都是Key的子集,因此这意味着它在3NF中

So this is one of the rare cases (according to wiki) where a relation is in 3NF but not in BCNF . 所以这是罕见的情况之一(根据wiki),其中关系是3NF不是 BCNF Is this method correct? 这种方法是否正确? Is it reliable? 它可靠吗? Am I missing anything? 我错过了什么吗?

First you need to learn superkeys, candidate keys, and primary attributes. 首先,您需要学习超级键,候选键和主要属性。

However, this rule of thumb helps: 但是,这个经验法则有助于:

A 3NF table that does not have multiple overlapping candidate keys is guaranteed to be in BCNF. 不具有多个重叠候选键的3NF表保证在BCNF中。

In other words, if the candidate keys in a 3NF relation are 换句话说,如果3NF关系中的候选键

  • all atomic, or 所有原子,或
  • non-atomic but non-overlapping, 非原子但不重叠,

it is guaranteed that the relation is in BCNF. 保证关系在BCNF中。

The simplest relation which violates BCNF but meets 3NF has the following functional dependencies: 违反BCNF但满足3NF的最简单关系具有以下功能依赖性:

A,B -> CC -> B

In this case, candidate keys are (A,B) and (A,C) . 在这种情况下,候选键是(A,B)(A,C)
It meets 3NF because 它满足3NF因为

  • the right-hand-side of all functional dependencies is a primary attribute . 所有功能依赖项的右侧是主要属性

It violates BCNF because 它违反了BCNF,因为

  • C -> B , but the left-hand-side is not a superkey . C -> B ,但左侧不是超级键

BCNF: BCNF:

X->Y where Y can be prime or non-prime X-> Y,其中Y可以是素数 或非素数
Here,X must be a super key 这里,X 必须超级密钥

3NF : 3NF

X->Y where Y is non-prime X-> Y,其中Y 是非素数
then, 然后,
X must be a super key X 必须超级密钥
else 其他
X need not be super key X 不一定超级密钥

Hope,this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM