简体   繁体   English

如何将表分解为3NF和BCNF

[英]How to decompose table to 3NF and BCNF

I found a relation this way - CUSTOMER (NAME, STREET, CITY, STATE, ZIP) 我以这种方式找到了一种关系- CUSTOMER (NAME, STREET, CITY, STATE, ZIP)

That use abbreviating for each following way, 对于以下每种方式都使用缩写,

Name - N
STREET - R
CITY - C
STATE - T
ZIP - Z

And given F = {N->RCT, RCT->Z, Z->CT} 并给定F = {N->RCT, RCT->Z, Z->CT}

And question is decompose to 3NF and BCNF . 而问题则分解为3NFBCNF

I decompose it to 3NF , In here I considered practical way, 我将其分解为3NF ,在这里我考虑了实用的方法,

R1(N,R,Z)
R2(Z,C,T)

Is it correct? 这是正确的吗?

Or do I have to consider only given functional dependencies for decompose. 还是只考虑给定的功能依赖项进行分解。 If I think this way and decompose to 3NF , then the answer will be 如果我这样考虑并分解为3NF ,那么答案将是

R1(N,R,C,T)
R2(R,C,T,Z)

Please someone advice me which way the correct way. 请有人建议我正确的方法。

Your first decomposition is not correct, while the second is. 您的第一个分解是不正确的,而第二个是。 To decompose in 3NF, the first step of the “synthesis” algorithm requires to find a canonical cover of the set of dependencies, and then group the dependencies found in groups with the same left hand side. 为了在3NF中进行分解,“合成”算法的第一步需要找到一组依赖项的规范覆盖,然后将组中找到的依赖项用相同的左手分组。

Since there are no redundant dependencies or superflous attribute in your dependencies, we can start from the three dependencies, that have a different left hand side, producing three relations: 由于您的依赖项中没有多余的依赖项或多余的属性,因此我们可以从左侧有不同的三个依赖项开始,产生三个关系:

 from N → RCT, R1 (N, R, C, T), with key N
 from RCT → Z, R2 (R, C, T, Z), with key RCT
 from Z → CT, R3 (C, T, Z), with key Z

then, noting that the third relation is completely contained in the second one, we can eliminate it. 然后,注意到第三个关系完全包含在第二个关系中,我们可以消除它。 The final formal step of the algorithm requires that we check if in some decomposed relation is present a key of the original relation (otherwise a new relation with the key should be added). 该算法的最后形式步骤要求我们检查是否在某个分解关系中存在原始关系的键(否则应添加与该键的新关系)。 This is true, since Z is such a key, which is present in the second relation. 这是正确的,因为Z是这样的键,它存在于第二种关系中。 So, the final decomposition is: 因此,最终分解为:

 R1 (N, R, C, T), with key N
 R2 (R, C, T, Z), with key RCT

Note that, by applying the “analysis” algorithms to find the BCNF we obtain a different solution: 请注意,通过应用“分析”算法找到BCNF,我们获得了不同的解决方案:

R1 <(N, R, C, T),
    { N → RCT }>

R2 <(C, T, Z),
    { Z → CT } >

R3 <(R, Z),
    { } >

but in this decomposition the functional dependency CRT → Z is lost. 但是在这种分解中,功能依赖性CRT → Z丢失了。

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

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