Super and Candidate Key
Super Key :
In order to understand super key in DBMS we must understand what is closure of an attribute.
Closure of an attribute :
We defined Functional dependency here Functional Dependency. Closure of an attribute is nothing but the set of Axioms that are applied to get all the implied rules from the given rules. You can study about the Axioms here Axioms
Let us take an example
A->B
B->C
A+=Closure of A ={A,B,C} (using transitive property and reflexive property)
B+=Closure of B ={B,C} (using reflexive property)
C+=Closure of C ={C} (reflexive property)
AB+=Closure of AB={A,B,C} (using transitive property and reflexive property)
Let us take an example
A->B
B->C
A+=Closure of A ={A,B,C} (using transitive property and reflexive property)
B+=Closure of B ={B,C} (using reflexive property)
C+=Closure of C ={C} (reflexive property)
AB+=Closure of AB={A,B,C} (using transitive property and reflexive property)
AC+=Closure of AC={A,B,C} (using reflexive property)
Super Key :
Having understood closure let us define what is superkey. Superkey is an attribute or set of attributes that define all attributes. we find superkey using closure. If closure of any set of attributes make all the attributes we say it as super key.
Let us work with an example :
FD's = {A->B,B->C, A->C}
A+={A,B,C}
AB+={A,B,C}
ABC+={A,B,C}
AC+={A,B,C}
The above are all the super key for the given example.
Let us work with an example :
FD's = {A->B,B->C, A->C}
A+={A,B,C} is the candidate key because only one attribute A is used.
Let us take another example :
FD's = {A->B,B->C, A->C,C->A}
Let us work with an example :
FD's = {A->B,B->C, A->C}
A+={A,B,C}
AB+={A,B,C}
ABC+={A,B,C}
AC+={A,B,C}
The above are all the super key for the given example.
Candidate Key :
Candidate key is minimal subset of super key i.e., with how many minimum attributes we can form a super key.
FD's = {A->B,B->C, A->C}
A+={A,B,C} is the candidate key because only one attribute A is used.
Let us take another example :
A+={A,B,C}
C+={A,B,C}
B+={A,B,C}
all are candidate keys because all use only one attribute.
C+={A,B,C}
B+={A,B,C}
all are candidate keys because all use only one attribute.
Comments
Post a Comment