问题
I have the following problem: R(ABCDEFG) and F ={ AB->CD, C->EF, G->A, G->F, CE ->F}. Clearly, B & G should be part of the key as they are not part of the dependent set. Further, BG+ = ABCDEFG, hence candidate key. Clearly, AB->CD violates BCNF. But when I follow the algorithm, I do not end up in any answer. Probably doing something wrong. Can anyone show me how to apply the algorithm correctly to reach the decomposition?
Thanks in advance.
回答1:
First, you should calculate a canonical cover of the dependencies. In this case it is:
{ A B → C
A B → D
C → E
C → F
G → A
G → F } >
Since the (unique) candidate key is B G
, no functional dependency satisfies the BNCF. Then, starting from any functional dependency X → Y
that violates the BCNF, we calculate the closure of X
, X+
, and replace the original relation R<T,F>
with two relations, R1<X+>
and R2<T - X+ + X>
. So, chosing in this case the dependency A B → C
, we replace the original relation with:
R1 < (A B C D E F) ,
{ A B → C
A B → D
C → E
C → F} >
and:
R2 < (A B G) ,
{ G → A } >
Then we check each decomposed relation to see if it satisfies the BCNF, otherwise we apply recursively the algorithm.
In this case, for instance, in R1
the key is A B
, so C -> E
violates the BCNF, and we replace R1
with:
R3 < (C E F) ,
{ C → E
C → F } >
and:
R4 < (A B C D) ,
{ A B → C
A B → D } >
two relations that satisfy the BCNF.
Finally, since R2
too does not satisfy the BCNF (beacuse the key is B G
), we decompose R2
in:
R5 < (A G) ,
{ G → A } >
and:
R6 < (B G) ,
{ } >
that are in BCNF.
So the final decomposition is constituted by the relations: R3
, R4
, R5
, and R6
. We can also note that the dependency G → F
on the original relation is lost in the decomposition.
来源:https://stackoverflow.com/questions/42794143/bcnf-decomposition-algorithm-not-working