简体   繁体   English

通过分解实现BCNF

[英]Achieving BCNF by decomposition

Here are two functional dependencies which hold for R. 这是两个适用于R的函数依赖项。

R(A,B,C,D,E) {ABCD->E, E->A} R(A,B,C,D,E){ABCD-> E,E-> A}

The answer from my friend is that it can be decomposed into BCNF. 我朋友的回答是,它可以分解为BCNF。

R1(B,C,D,E) {BCD->E} R1(B,C,D,E){BCD-> E}

R2(A,E) {E->A} R2(A,E){E-> A}

However, I think that it cannot be true because the original functional dependency ABCD->E has not been preserved. 但是,我认为这是不正确的,因为尚未保留原始的功能依赖项ABCD-> E。 Therefore, in my opinion, R can not be decomposed into BCNF because the original functional dependency ABCD->E has not been preserved. 因此,在我看来,R不能分解为BCNF,因为尚未保留原始的功能依赖性ABCD-> E。 Am I right or wrong? 我是对还是错?

R can be decomposed in BCNF. R 可以在BCNF中分解。 Using the classical analysis algorithm the result is: 使用经典分析算法,结果为:

R1(A, E) {E → A}

and

R2 (B, C, D, E) {}

But the decomposition causes the loss of the dependency ABCD → E . 但是分解会导致依赖性ABCD → E的损失。 Note that the decomposition in your question is still in BCNF, but still that decomposition causes the loss of the same dependency (and in R1 the dependency BCD → E does not hold). 请注意,在你的问题分解仍然在BCNF,但仍然是分解导致相同的依赖损失(和R1的依赖BCD → E 成立)。

(In the first version of this question you say, "the original primary key has been broken". You seem to mean, the original FD (functional dependency) has been "broken". (Otherwise, your statement doesn't make sense.) Instead of writing/thinking vague things like "broken", make the effort to write/think something clear and precise using appropriate technical terms. Eg when the components satisfy their FDs their join doesn't necessarily satisfy that original FD. For which there happens to be a more specialized phrase: the FD has not been preserved.) (在此问题的第一个版本中,您说“原始主键已损坏”。您似乎是说,原始FD (功能依赖性)已被“损坏”。(否则,您的声明没有意义。 )不要用适当的技术术语来写/认为“破”之类的含糊不清的东西,而要努力地用适当的技术术语来写/想清楚,精确的东西。恰好是一个比较专业的词:FD未保存。)

We can always normalize to BCNF. 我们总是可以归一化为BCNF。 But not necessarily preserving all FDs. 但不一定保留所有FD。

If someone claims a decomposition is to BCNF, and that certain FDs hold in the components, then they should back it up by showing how they got that from a BCNF decomposition algorithm. 如果有人声称分解是针对BCNF的,并且某些FD包含在组件中,那么他们应该通过显示如何从BCNF分解算法中得到它来进行备份。 (There are other ways to prove it from definitions, which is how the algorithms were proved to work.) You can decompose to those components , and A->E holds in R2, but BCD->E doesn't hold in R1. (还有其他从定义中证明算法的方法,这就是证明算法有效的方式。)您可以分解为这些组件 ,并且A-> E在R2中成立,但BCD-> E在R1中不成立。 And ABCD->E is not preserved. 并且不保留ABCD-> E。 There's no way to preserve it in decomposing to smaller components, because no smaller component has all those attributes. 没有办法在分解为较小的组件时保留它,因为没有较小的组件具有所有这些属性。

You can also show that {R1,R2} is a lossless decomposition of R via a theorem that says that a binary decomposition is lossless when (if and only if) the common columns include a CK (candidate key) of one of them. 您还可以通过一个定理证明{R1,R2}是R的无损分解,该定理说(当且仅当)公共列包括其中之一的CK(候选关键字)时,二进制分解才是无损的。 Here the common column set is {E}, which includes itself, which is a CK of R2, so the decomposition is lossless. 这里,公共列集为{E},其中包括自身,它是R2的CK,因此分解是无损的。 You can show they are both in BCNF via a definition of BCNF. 您可以通过BCNF的定义显示它们都在BCNF中。 Here, in each component all determinants of non-trivial FDs are superset of CKs, so each is in BCNF. 在这里,在每个分量中,非平凡FD的所有决定因素都是CK的超集,因此每个都在BCNF中。

Components are always projections of an original that join back to it. 组件始终是原始文档的投影,并重新连接到原始文档。 So in any business situation that would have set the original to a certain value, the components will be set to projections of it and will join back to the original. 因此,在将原件设置为特定值的任何业务情况下,组件都将设置为原件的投影并将重新加入原件。 So the FD will hold in the join. 因此,FD将保留在联接中。 But if an FD is not preserved then if we constrain (error check) the attempted updates of the components per their FDs then we don't end up constraining (error checking) the original per that FD. 但是,如果未保留FD,则如果我们根据组件的FD约束(错误检查)组件的尝试更新,那么我们就不会最终根据该FD约束(错误检查)原始组件。 So to prevent erroneous updates to the components & join we need to add a different constraint. 因此,为了防止错误地更新组件和联接,我们需要添加其他约束。

PS Now you can ask yourself, why do you think you have an opinion about FDs being preserved in BCNF? PS现在您可以问自己,您为什么对BCNF中保存的FD有意见? In math we don't have opinions, we have proofs of theorems. 在数学中,我们没有意见,有定理证明。 If you think you can show or reference that it's wrong, ask whether that justification is correct. 如果您认为可以证明或引用是错误的,请询问该证明是否正确。 If you don't have a proof or reference, don't think you have an opinion. 如果您没有证据或参考,请不要认为您有意见。 If you don't really mean you have an opinion, then don't say that you do, say what you do mean. 如果你真的不意味着你有意见,那就不要说你,说是什么意思。 Also for the future--how could you have answered this? 同样为了未来-您如何回答这个问题? You must have been given a reference, and many are available including free online. 您必须已获得参考,并且可以找到许多参考资料,包括免费在线。 You have learned something about BCNF. 您已经了解 BCNF。 If you had read the whole section on BCNF it would have told you that FDs can't always be preserved. 如果您已经阅读了BCNF的整个部分,那么您会发现FD不能总是被保留。 So please do due research before you ask a question. 因此,在提出问题之前,请做适当的研究。

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

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