Super key is basically a superset of a key. It is a non-minimal Candidate Key, that is to say one with additional columns not strictly required to ensure uniqueness of the row. Super key is set or one of more columns to uniquely identify rows in a table. The super key is a PK with additional attributes.
Candidate keys are selected from set of super keys. A relation/table can have one or more than one Candidate Keys. A Candidate key is also known as a minimal Super key. It is a super key which cannot have any columns removed from it without losing the unique identification property. This property is sometimes known as minimality or irreducibility. Each CK can qualify as a Primary Key. For a Candidate Key to qualify as a PK , it should be unique and non-null.
A Primary Key is a minimal Candidate Key, which is to say all constituent columns are strictly required in order to ensure uniqueness. Primary keys are selected from the set of candidate keys. A primary key column cannot contain NULL values.
Lets take an example to understand it more clearly, Suppose we have a table
Book (BookId, BookName, Author)
In the above table we can have ,
- (BookId, BookName)
- (BookName, Author)
- (BookId, BookName, Author)
- (BookId, Author)
As our Super Key , Each super key is able to uniquely identify each tuple (record).
As told above Candidate keys are super key which are not having any redundant attributes. For Example, from above
These 2 keys can be candidate keys, as remaining keys are having redundant attributes , i.e. in super key (BookId, BookName) record can be uniquely identified by just bookid and hence Bookname is redundant attribute . From above Candidate keys any one can be the primary key.