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.
Related
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).
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?
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).
This might very simple but I just had to check with you guys.
When it comes to databases, does the arrow in literature imply vise versa on equality?
Meaning, is A → B considered the SAME as B → A, in particular when it comes to databases and functional dependencies?
Please read the reference(s) you were given for FDs (functional dependencies).
A FD is an expression of the form "A → B" for sets of attributes A & B. So if A and B are different, A → B is a different FD than B → A.
For a relation value or variable R, "A → B holds in R" and "A → B in R" say that if two R tuples have the same subtuple for A then they have the same subtuple for B.
Is A → B in R equivalent to B → A in R? If A and B are the same set, then yes. But what if they aren't?
X Y
a 1
b 1
{X} → {Y} holds in that relation value. {X} <> {Y}. Does {Y} → {X} also hold?
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.