Super Keys: Super Key stands for superset of a key.
A Super Key is a set of one or more attributes that are taken collectively and can identify all other attributes uniquely.
For example, consider the table:
Book (BookId, BookName, Author)
So in this table we can have
- (BookId, BookName)
- (BookId, BookName, Author)
- (BookId, Author)
- (BookName, Author)
As our Super Key. Each Super Key is able to uniquely identify each tuple (record).
Candidate Keys: Candidate keys are a Super Key which are not having any redundant attributes.
In other words candidate keys are minimal Super Keys.
For example, in the above illustration
These two keys can be candidate keys, as remaining keys are having redundant attributes.
Means in Super Key
(BookId, BookName) record can be uniquely identify by just
BookId and therefore
BookName is redundant attribute.
Primary Key: It is a candidate key that is chosen by the database designer to identify entities with in an entity set.
A key which is used to uniquely identify each record is known as primary key.
From above Candidate keys any one can be the primary key.
And the another one which is not chosen as primary key will be know as Alternate key