Tuesday, June 14, 2016

Find the key of a given relation R

How to find the key of a relation R?, Easy way to find the candidate key of a table




Question:
7. Consider a relation R with set of functional dependencies F as follows; {A B, C D, AC E, D F}. How many keys does R have and what are they?

Solution:
Closure:
In simple terms, if you know an attribute (or set of attributes) in a relation R, then what other attribute (or set of attributes) you would determine uniquely is called the closure. We normally find the closure of left hand side (LHS) attributes of the functional dependencies of relation R. Closure is used to find the candidate keys of the relation. Refer here to know more about attribute closure.

If we find the closure of all the left hand side attributes of all the FDs given, we would find the keys of R. If the closure includes all the attributes of R then that closure is one of the keys of R.
Let us find the closure of A, i.e., A+;
Result = A
Result = AB from A B (if you know, then you know B uniquely)
We don’t have any other FDs that have either A or B or both on the left hand side. Hence, our algorithm stops here and the result is AB.
The closure of A is AB. (not a key because A+ does not contain all the attributes of R)
Let us find the closure of C, i.e., C+;
Result = C
Result = CD from C D
Result = CDF from D F
We don’t have any other FDs that have either C or D or F or any combinations on the left hand side. Hence, our algorithm stops here and the result is CDF.
The closure of C is CDF. (not a key because C+ does not contain all the attributes of R)
Let us find the closure of AC, i.e, (AC)+;
Result = AC
Result = ABC from A B
Result = ABCD from C D
Result = ABCDF from D F
Result = ABCDEF from AC E
The closure of AC is ABCDEF which is R. Hence, AC is the only key of R.

**********************


Similar topics

How to find closure of set of functional dependencies?

How to find closure of attributes?

How to find canonical cover for a set of functional dependencies?

How to find extraneous attribute?




Go back to Question/QUIZ page






Steps to find candidate keys that are holding in a relation R

Write down the steps to find all the candidate keys of a relation R in dbms







No comments:

Post a Comment

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery