简体   繁体   English

BCNF分解查询

[英]BCNF decomposition query

I have a relation R(A, B, C, D) with functional dependencies ABC --> D and D --> A . 我有一个关系R(A,B,C,D),具有函数依赖关系ABC-> DD-> A。

The question was, does this have a BCNF, and the answer was as follows: 问题是,这是否具有BCNF,答案如下:

在此处输入图片说明

(c) ABCD is not in BCNF since D --> A and D is not a key. (c) ABCD不在BCNF中,因为D- > AD不是密钥。 However, if we split up R as AD , BCD , we cannot preserve the dependency ABC --> D . 但是,如果将R拆分为ADBCD ,则无法保留依赖项ABC- > D。 So there is no BCNF decomposition. 因此,没有BCNF分解。

Now my question is, I understand that ABC->D cannot be preserved if you split the relation R into R1(A,D) and R2(BCD) but what if you changed R2(BCD) to R2(ABCD) . 现在我的问题是,我知道如果将关系R拆分为R1(A,D)R2(BCD)不能保留ABC-> D 但是如果将R2(BCD)更改为R2(ABCD)怎么办? Wouldn't that preserve it then? 那不会保留吗? Is there any reason we cannot do that? 有什么理由我们不能这样做吗?

You are taking "So there is no BCNF decomposition" out of context in two ways. 您通过两种方式脱离上下文考虑“因此,没有BCNF分解”。 There is no (lossless) BCNF decomposition (1) into relations that are all smaller (per comment ) (2) that preserves all FDs (per comment ). 没有(无损的)BCNF分解(1) 变成较小的关系 (每个注释 )(2) 保留所有FD (每个注释 )。

From this answer : 这个答案

[O]ne can always losslessly decompose to 3NF while preserving FDs but BCNF might not preserve them. [O] ne在保留FD的同时始终可以无损地分解为3NF,但BCNF可能不会保留它们。 Nevertheless it's a lossless decomposition: the components, if holding projections of the original, will join to the original. 但是,这是无损的分解:如果组件具有原始图元的投影,则它们将合并到原始图元中。 But whenever the original would have had a given value, the components should be projections of it. 但是,只要原件具有给定的值,组件就应该是它的投影。 (If they're not, an error has been made, so we want the DBMS to constrain the components appropriately.) So it is necessary but sufficient to constrain the components to be projections of the original. (如果不是,则会出错,因此我们希望DBMS适当地约束组件。)因此,有必要但有必要将组件约束为原始投影。 ABC is trivially so (because it is a key). ABC很简单(因为这是关键)。 This leaves us needing to require that AD = ABCD PROJECT {DA}. 这使我们需要要求AD = ABCD PROJECT {DA}。 We say that the components must satisfy that "equality dependency". 我们说组件必须满足“平等依赖”。

You can always non-loss decompose to 5NF. 您始终可以将无损分解为5NF。 You just might have to add equality dependency constraints if you want to constrain the components per the unpreserved FDs. 如果要根据未保留的FD约束组件,则可能只需要添加相等依赖项约束。

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

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