Tuesday, 11 July 2017

Find the key of relation R

Find the candidate keys of a relation, How to find the candidate keys, Which is the key for the given table, concept of candidate key in dbms, candidate key examples

Consider the relation R = {A, B, C, D, E, F, G, H, I, J} and the set of functional dependencies F = {AB C, A DE, B F, F GH, D IJ}. Find the key of relation R.

We can find keys (candidate keys) for a relation by finding the closure of an/set of attributes. Checking each attribute or all subsets of the given set of attributes for a key is time consuming job. Hence, we may employ some of the following heuristics/assumptions in identifying the keys;

  • We may start checking all the left hand side attributes of any/all of the given set of functional dependencies. We can start with single LHS attributes.
  • If we find the closure of an attribute and that attribute is the candidate key then any superset cannot be the candidate key. For example, if A is a candidate key, then AB is not a candidate key but a super key.

= ADE from the functional dependency A DE (By reflexivity rule)
= ADEIJ from D → IJ (By transitivity rule. A → D and D → IJ hence A → IJ)
No more functional dependencies that has either of the attributes ADEIJ in LHS. Hence, A+ = ADEIJ.
A+ ≠ R.
So, A is not a candidate key.
= BF from B → F (By reflexivity rule)
= BFGH from F → GH (By transitivity rule)
No more functional dependencies that has either of the attributes BFGH in LHS. Hence, B+ = BFGH.
B+ ≠ R.
So, B cannot be a candidate key.

= ABC from AB C
= ABCDE from the functional dependency A DE
= ABCDEIJ from D → IJ
= ABCDEFIJ from B → F
(AB)+ = R.
So, (AB) is the candidate key.

Go to - 1NF,    2NF,    3NF,    BCNF


Find the keys of a relational table in dbms solved problem

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