The Problem "Consider a relation R with five attributes ABCDE. You are given the following dependancies
- A->B
- BC->E
- ED->A
List all the keys for R.
The teacher gave us the keys, Which are ACD,BCD,CDE
And we need to show the work to get to them.
The First two I solved.
For BCD, the transitive of 2 with 3 to get (BC->E)D->A => BCD->A.
and for ACD id the the transitive of 1 with 4 (BCD), to get (A->B)CD->A => ACD->A
But I can't figure out how to get CDE.
So it seems I did it wrong, after googling I found this answer
- methodology to find keys: consider attribute sets α containing: a. the determinant attributes of F (i.e. A, BC, ED) and b. the attributes NOT contained in the determined ones (i.e. C,D). Then do the attribute closure algorithm: if α+ superset R then α -> R Three keys: CDE, ACD, BCD Source
From what I can tell, since C,D are not on the left side of the dependencies. The keys are left sides with CD pre-appended to them. Can anyone explain this 开发者_如何学Goto me in better detail as to why?
To get they keys, you start with one of the dependencies and using inference to extend the set.
Let me have a go with simple English, you can find formal definition the net easily.
e.g. start with 3).
ED -> A
(knowing E and D, I know A)
ED ->AB
(knowing E and D, I know A, by knowing A, I know B as well)
ED->AB
Still, C cannot be known, and I have used all the rules now except BC->E, So I add C to the left hand side, i.e.
CDE ->AB
so, by knowing C,D and E, you will know A and B as well, Hence CDE is a key for your relation ABCDE. You repeat the same process, starting with other rules until exhausted.
精彩评论