简体   繁体   中英

How to decompose table to 3NF and BCNF

I found a relation this way - 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}

And question is decompose to 3NF and BCNF .

I decompose it to 3NF , In here I considered practical way,

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

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.

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. 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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