How to transform this into Boyce-Codd Normal Form? - database

I don't understand what I am doing wrong here. This is what I am being asked:
Normalize the following schema into BNCF:
T ((A, B), C, E, F, G)
The functional dependencies besides the key are:
A, B → C, E
F, B, A → G
B → B
F, C → C, G, E
C, F → E
E → G, E
So, I came up with this:
T ((A, B), C, E, F)
X((A,B), C, E)
W ((F,B,A), G)
Q ((B))
L ((F,C), G, E)
J ((C,F), E)
R ((E),G)
But it gives me this error:
Result is not as expected. Modify your input and try again.
And I have no clue where the error is. Can someone explain to me what I should do?

If the nested parentheses indicate a CK (candidate key) then
A, B → C, E is implied by the CK
F, B, A → G ditto
B → B is trivial
F, C → C, G, E is implied by F, C → G, E
C, F → E is redundant given F, C → G, E
E → G, E means F, C → G, E is implied by F, C → E
{A, B} being a CK means A, B → C, E, F, G, plus we have F, C → E and E → G. We can use a BCNF algorithm to get a decomposition comprising ((A, B), C, F) plus your J ((C,F), E) and R ((E), G).
You don't explain your solution (what BCNF algorithm you are using and what choices you made). But note that the FDs that hold in a relation are all the ones generated by Armstrong's axioms when some explicitly given ones hold. (Including the ones that hold because we were told a CK.) Also note that in one BCNF algorithm when we pick some FD (functional dependency) X → Y that holds in schema R that violates BCNF we replace R by schemas X+ and R - (X+ - X); and the set of FDs used is the closure of the explicitly given ones.

Related

Finding the canonical cover? [duplicate]

I have a relation r(A,B,C,D,E,F) satisfying:
AB->C
C->A
BC->D
ACD->B
BE->C
CE->FA
CF->BD
D->EF
I need to find the canonical cover for this relation?
I know the algorithm to find the canonical cover. However in the algorithm, we need to find the extraneous attributes. Is there an algorithm to find extraneous attributes?
The algorithm to find extraneous attributes is the following:
let F the initial set of functional dependencies
assume that each dependency F is in the form A1, A2, ..., An -> B
for each functional dependency A1, A2, ..., An -> B in F with n > 1
for each Ai
if B ∈ ({A1, A2, ..., An} - Ai)+
then Ai is an extraneous attribute and must be removed from the left hand side
Note that the closure of the remaining attributes must be computed by considering all the dependencies of F, including the dependency under examination (this can be counterintuitive).
For instance, applying this algorithm to your example, starting from the dependencies:
{ A B → C
A C D → B
B C → D
B E → C
C → A
C E → A
C E → F
C F → B
C F → D
D → E
D → F }
In A C D → B, A is estraneous since {C D}+ = (A B C D E F), while in C E → A, E is estraneous since {C}+ = (A C).

Did I do this BCNF decomposition correctly?

Given schema R = (A, B, C, D, E, G) and functional dependencies :
F = { A -> BC, BD -> E, AD -> E, CD -> AB }
BCNF decomposition:
A -> BC, but A is not a superkey of R. Replace R by 2 relations: R1(A, B, C) and R2(A, D, E, G).
AD -> E holds on R_2, but AD is not a superkey for R2. Replace R2 by 2 relations: R2(A,D,E) and R3(A,D,G)
Left with R1(A,B,C), R2(A,D,E), R3(A,D,G)
It is not dependency preserving as you would need to do a join to compute BD -> E.
Did I do this decomposition correctly? Also, how can I determine if it is a lossless decomposition?

How to find the extraneous attributes of functional dependency?

I have a relation r(A,B,C,D,E,F) satisfying:
AB->C
C->A
BC->D
ACD->B
BE->C
CE->FA
CF->BD
D->EF
I need to find the canonical cover for this relation?
I know the algorithm to find the canonical cover. However in the algorithm, we need to find the extraneous attributes. Is there an algorithm to find extraneous attributes?
The algorithm to find extraneous attributes is the following:
let F the initial set of functional dependencies
assume that each dependency F is in the form A1, A2, ..., An -> B
for each functional dependency A1, A2, ..., An -> B in F with n > 1
for each Ai
if B ∈ ({A1, A2, ..., An} - Ai)+
then Ai is an extraneous attribute and must be removed from the left hand side
Note that the closure of the remaining attributes must be computed by considering all the dependencies of F, including the dependency under examination (this can be counterintuitive).
For instance, applying this algorithm to your example, starting from the dependencies:
{ A B → C
A C D → B
B C → D
B E → C
C → A
C E → A
C E → F
C F → B
C F → D
D → E
D → F }
In A C D → B, A is estraneous since {C D}+ = (A B C D E F), while in C E → A, E is estraneous since {C}+ = (A C).

Determining BCNF violations

So I have a relation schema with FD's that look like this:
R(A,B,C,D): AB -> C, B -> D, CD -> A, AD -> B
Now I'm trying to find all the BCNF violations and then decompose the tables. I computed the left hand side of all the FD's and found this:
AB+ = {A, B, C, D}
B+ = {B, D} <- violation
CD+ = {C, D, A, B}
AD+ = {A, D, B, C}
So I decompose the table to look like this:
R1 (B, D)
R2 (A, B, C)
The only problem is that I'm not sure if this is all I have to do when it comes to decomposing the tables or if I have to do more. I'm mainly confused about the AB, CD, and AD parts.
In your example, B → D is in effect the only dependency that violates the BCNF, since in all the other depedencies the left hand side is a key (actually all the keys of the relation are (A D), (A B), (B C) and (C D)).
So, you can decompose by splitting the original relation R in R1, containing B+, that is BD, and R2, containing R - B+ + B, that is ABC, as you have correctly found.
Then one should apply again this process if in any of the decomposed relation there is some dependency that violates the BCNF. But this is not the case, since the only dependency in R1 is B → D, with B the only key, and with the dependencies AB → C and BC → A in R2, that has keys AB and BC.
At this point can terminate the process since R1 and R2 are both in BCNF. But we should note also that this decomposition does not preserve the dependencies, since CD → A and AD → B have been lost.

Can BCNF decomposition preserve all functional dependencies given F = {AB -> E, BC -> G, C-> BG, CD->A, EC->D, G->CH}?

Given F = {AB -> E, BC -> G, C-> BG, CD->A, EC->D, G->CH}, perform a BCNF decomposition and check whether it preserves all functional dependencies.
The minimal cover is R = {AB->E,C->B,C->G,CD->A,EC->D,G->C,G->H}
I performed on R a BCNF decomposition(it is a must to perform on the minimal cover) and I stayed with two dependencies of which one is preserved and one isn't preserved. In the answers they tell me that all of the dependencies are preserved. Can please anyone confirm this?
ABE, CBG, CDA, CED, GCH are in BCNF and loosless join and dependency preserving. relation keys are in bold
There is always a possibility to add a new relation for preserving a dependency as long as this new relation is in BCNF.
Starting from the canonical cover, we can see that the determinant of A B → E is not a superkey and so R can be replaced by:
R1 < (A B E) , { A B → E } >
and:
R2 < (A B C D G H) ,
{ G → C
G → H
C → B
C → G
C D → A
A B C → D } >
In R2 the determinant of G → C is not a superkey and so R2 can be replaced by:
R3 < (B C G H) ,
{ G → C
G → H
C → B
C → G } >
and:
R4 < (A D G) ,
{ D G → A
A G → D } >
So, the final decomposition is:
R1 < (A B E) ,
{ A B → E } >
R3 < (B C G H) ,
{ G → C
G → H
C → B
C → G } >
R4 < (A D G) ,
{ D G → A
A G → D } >
and the dependency:
{ C E → D }
is not preserved.

Resources