Explain with an example How to find candidate keys from a set of super keys?
Explain with an example How to find candidate keys from a set of super keys?
From all the super keys available, the candidate key is the one whose proper subset is not a super key. Let’s see it with an example.
given set of super key is:
ABC-> ABC
AB -> C
BC -> A
A -> BC
Given ABC key, we’re saying if we find its proper subset i.e. {A, B, C, AB, AC, BC} and any of them can be a key then ABC can’t become a candidate key.
Given ABC key, we’re saying if we find its proper subset i.e. {A, B, C, AB, AC, BC} and any of them can be a key then ABC can’t become a candidate key.
AB, which comes from the proper subset of ABC, is also a key. Therefore, ABC is not a candidate key.
Note: If x is a proper subset of y then x must NOT have one element that is included in y. Example,
X = {1,2,3} Y = {1,2,3,4}
Here, we can say X is a proper subset of Y since X doesn’t have 4 in it.
Similarly, AB is also not a candidate key because we have got A in its proper subset which can be used as a key. Therefore, at last, we found that A is the ONLY candidate key available for the above schema.
To get a detail information regarding different types of keys in dbms check out: https://www.scaler.com/topics/keys-in-dbms/
17 People are following this question.