I am having some trouble with this textbook question.
Find the minimal cover for the relation R(A,B,C,D,E,F,G,H,I),
where the functional dependencies are:
E->B,I,H,D
I->F
A->C
F,C->G
B->D
How do I get rid of the extraneous LHS attribute? Also, how do I find the key for this relation?
Thanks.
There's a transitive dependency in E->B,I,H,D since B->D, thus you can remove D from the RHS of E. I see no other redundant dependencies. If you follow the arrows in reverse, you'll see that R is determined by E,A.
Because E -> I, I -> F, F,C -> G, can you therefore remove the C from F,C -> G Giving you a minimal cover of:
E -> B
E -> I
E -> H
I -> F
A -> C
F -> G
B -> D
Related
I am trying to solve an exercise related with functional dependencies and database normalization. I have solved many exercises similar to this one but I can not solved this.
For a given a Schema with a single relation R(A, B, C, D, E, F), the set of all functional dependencies that holds is:
BC -> DC
B -> E
D -> EF
FC -> E
C -> A
F -> E
Normalize the relation R so it satisfies the 2NF AND all Functional dependencies are kept.
What I have done so far:
1) Find candidate keys: {BC} (I think there is a single candidate key)
2) Find a minimal equivalent set of dependencies
BC → D
B → E
D → EF
C → A
F → E
3) use C → A (A depends on C that is part of the candidate key, A is non prime)
R1(B, C, D, E, F), candidate keys BC
R2(C, A) candidate keys C
4) use B → E (E depends on B that is part of the candidate key, E is non prime)
R2(C, A) candidate keys C
R11(B, C, D, F) candidate keys BC
R12(B, E) candidate keys B
I do not like this normalization because the functional dependency F -> E can not be recovered. I am looking for a decomposition of R such that the second normal form is satisfied and no functional dependency is lost. Can anybody help me to find such decomposition?
I have a relation and function dependencies as follows:
R = (A, B, C, D, E)
F = (A -> B C,
B C -> D,
A C -> D E)
Now I am going to compute the minimal/canonical cover using this video.
So firstly I check if I have singleton right-hand sides in my FDs. No I don't, so I have to split them up. I.e. A -> B C is split into A -> B and A -> C. Similarly for A C -> D E.
So now I have...
F = (A -> B,
A -> C,
B C -> D,
A C -> D,
A C -> E)
Secondly, I check if any FDs have more than 1 LHS attributes. If they do, I see if any one of them can be eliminated by checking if their closure contains the other element. If it does, then we don't need that other element.
So for B C -> D, B closure is B and C closure is C. None of the closures contain the other attribute so we cannot eliminate B C -> D.
So now we move to A C -> D. A closure is ABCDE, we can instantly see that A's closure contains C. So C is and extraneous attribute and can be removed so our new set of FDs is...
F = (A -> B,
A -> C,
B C -> D,
A -> D,
A C -> E)
So now we move to the last one: A C -> E, again, A's closure is ABCDE, which contains C so we can eliminate the C from the FD. So our set of FDs is now:
F = (A -> B,
A -> C,
B C -> D,
A -> D,
A -> E)
Lastly, we check if there are any redundant FDs. We do this by going through each FD, covering it up, and seeing if the closure of its LHS contains its RHS.
So for A -> B, we cover it up and compute A closure, which is ACDE which doesnt contain B so we cannot eliminate A -> B. We do this for all FDs and we end up seeing that we can only eliminate A -> D because when we cover A -> D up and compute A closure it contains D, so we don't need A -> D
So now our new set of FDs are:
F = (A -> B,
A -> C,
B C -> D,
A -> E)
Now my question is:
Is my final set of FDs the correct minimal/canonical cover? Can it be written in another way? Also, In the video, it says that multiple canonical covers can exist for a given set of functional dependencies. How can I discover these?
Thank you for your time.
For eg.
X→YZ
Y→XZ
Z→XY
check out this answer with more than one possibility of minimal set
1:
X→Y,
Y→Z,
Z→X
2:
Z→Y,
Y→X,
X→Z
I checked all your steps and your final set is correct.
That said, I'm not sure about the multiple covers thing. The only difference between minimal cover and canonical cover is that a canonical cover is "allowed" to have more than one attribute on the right hand side, whereas minimal cover is not [source]. In this (trivial) sense you could obviously write the same set FDs in a different way.
On the other hand, I don't know if there could be two different sets of minimal covers with the same closure. I would say it is impossible, but that's just my intuition and I don't have elements to back it up.
I have been trying to understand the process of decomposing a relation but with no succes. I have no idea how it works and I can't figure it out. I have an example here if someone could explain me step by step how it works.
Consider schema R(A;B;C;D;E) with FDs
F = {AB -> CDE; AC -> BDE; B -> C; C -> B; C -> D; B -> E}.
1. Find all keys of R.
F = {AB -> CDE; AC -> BDE; B -> C; C -> B; C -> D; B -> E}
A+ = A
B+ = BCED
- it is not possible to deduce A from the other attributes -> A belongs to key
AB+ = ABCDE - a candidate key
AC+ = ACBDE - a candidate key
AD+ = AD,
AE+ = AE
ADE+ = ADE
I also don't understand what A+ signifies
What you've posted isn't decomposing a relation. It's finding the candidate keys. The candidate keys here are {AB, AC}.
Finding the keys is the second step in decomposing a relation. The first step is identifying all the dependencies. You're given all the functional dependencies, so you don't have to do that part here.
A+ means "the closure of the set of attributes A with respect to the set of functional dependencies F"--the set of attributes of F that can be determined by A.
This statement
it is not possible to deduce A from the other attributes -> A belongs
to key
should be
it is not possible to deduce A from the other attributes -> A belongs
to every candidate key
I am trying to decompose the following relationships in to 3NF:
A -> BCD
BC -> DE
C -> D
D -> A
So I eliminated the redundancy to get the canonical cover:
A -> BC
B -> E
C -> D
D -> A
And now I am trying to decompose this into 3NF.
Should I decompose into r1(A, B, C) r2(B, D), r3(C, D). Then what do I do with D -> A?
The fact that A -> B -> D -> A is throwing me off.
Given
A -> BCD
BC -> DE
C -> D
D -> A
to obtain a canonical cover we first remove D from BC->DE:
A -> BC
BC -> E
C -> D
D -> A
Next, we observe that C->D, D->A, A->BC and if we know B->E, then we also know C->E. Hence,
A -> BC
B -> E
C -> D
D -> A
3NF decomposition works as follows:
1) Create tables for each dependency in the canonical cover
R1(A,B,C) R2(B,E) R3(C,D) R4(A,D)
2) Determine candidate keys of R. If no candidate keys are contained in the tables of step 1, add a new table containing only attributes of a candidate key.
Here A is a candidate key and it is contained in R1 (and R4), so no new tables should be added.
3) If there is a table such that its attributes are a subset of attributes of another table, remove the "contained" table.
This is not applicable, so the 3NF decomposition remains unchanged.
As you see, circular dependencies are not problematic.
I am kind of confused on the notion of extraneous attributes and a proper decomposition into 3NF.
For example, I have the following relation:
r(A,B,C,D,E,F)
F = FD's
F = {A-> BCD, BC-> DE, B->D, D->A}
I want to compute the canonical cover in order to decompose it into 3NF using an algorithm. So I have to remove extraneous attributes from the FD's.
I computed A+. B+, C+, D+ (A+ = ABCDE, B+ = BD, C+ = C, D+ = AD)
I started trying to find extraneous attributes. First I looked at attributes in β
I tried to find if D is extraneous in
BC -> DE
and using BC+ I found D is extraneous (Since BC+ contains the attribute D).
So now my FD changed from BC -> DE to BC -> E
Now I tried to compute extraneous attributes for α.
I looked to see if B or C is extraneous in FD BC -> DE (Computing B+ and C+ led me to neither B or C being extraneous since none of them contain E).
I also looked at extraneous attributed in A -> BCD and found both B and C to be extraneous (Since A+ contains all attributes). So I was left with following:
A -> D
BC -> E
B -> D
D -> A
Sorry for the extremely long question, I just wanted to write down what I did.
I am confused as to if this is correct or if I am even doing this correctly. I am trying to follow some notes and some online references but it would be nice if someone could point out if I am doing this right and if not try and explain somewhat as to properly find extraneous attributes and decomposing.
Some of your closures are wrong (B+ = ABCDE, for instance due to B->D,D->A,A->BCD,BC->DE).
B and C are not extraneous in A->BCD. Indeed, the closure of A with respect to
{A -> D, BC -> E, B -> D, D -> A}
is AD rather than ABCDE.
So let us backtrack to your previous step:
{A-> BCD, BC-> E, B->D, D->A}
D is extraneous in A->BCD since A->B and B->D. We eliminate D from A-> BCD and obtain:
{A-> BC, BC-> E, B->D, D->A}
C is extraneous in BC->E. Indeed, B->D, D->A, A-> BC. Hence,
{A-> BC, B-> E, B->D, D->A}
Next we combine all fds with the same left-hand side:
{A-> BC, B-> DE, D-> A}
This set of functional dependencies does not contain redundant dependencies or extraneous attributes, and, hence, is a canonical cover.