Search code examples
mysqlsqldatabaserelationcandidate-key

Find the SuperKeys


I am doing some textbook exercises that ask to find out the candidate keys for relation R as well as the superkeys.

I have solved for the candidate keys, but I am not sure how to solve for superkeys? I am just a bit confused.

Here is the relation schema and functional dependencies:

Relation Schema: **S(A, B, C, D)** 

**FD's:**

A-->B

B-->C

B-->D

So I have found that {A, AB} are the candidate keys after solving for that. I am just not sure how to find the superkeys for this. Any help would be greatly appreciated. Thank you all.


Solution

  • To find the candidate keys, you need to see what path leads you to all attributes using the dependencies. So you are correct about A because from A you can reach B that can reach {C, D}. AB can't be considered a candidate key because it has never been mentioned in your dependencies. Another way to think about it is by remembering that candidate key is the minimum number of attributes that guarantees uniqueness in your rows. But since A is already a candidate key then AB is not minimal set. Since you only have one candidate key that's A. A is called a key attribute and all other attributes are called non-key attributes. then you decide the number of super keys by 2 to the power of number of non-key attributes (B, C, D). In this scenario you should have 8 super keys. The way to find them is simply by mashing A with all possible combinations of the non-key attributes. So your superkeys would be A, AB, AC, AD, ABC, ABD, ACD, ABCD.