SuperKey vs CandidateKey(Primary Key)


Super Key: a super key is a set of columns that uniquely defines a row.


Table Definition:
StudentID
FirstName
LastName
Gender
Age
Class
Address
PhoneNumber

In the above example, StudentID uniquely defines a row. and superkey is any combination that uniquely identifies a row. so a superkey is any combination that contains studentID

studentID
studentID, FirstName
studentID, FirstName, LastName
studentID, FirstName, Gender
studentID, FirstName, Age
studentID, Firstname, Class
studentID, Firstname, Adress
studentID, FirstName, PhoneNumber
studentID, LastName, Gender
studentID, LastName, Age
studentID, LastName, Class
studentID, LastName, Adress
studentID, LastName, PhoneNumber
etc..........

if PhoneNumber is unique, then the list will be increased.

CandidateKey: A Candidate Key is simply the "shortest" superKey.
so, studentID is CandidateKey
PhoneNumber is CandidateKey

PrimaryKey: A Primary Key is just a CandidateKey

No comments:

Post a Comment