What are the differences between a super key and a candidate key? I have already referred to wiki,dotnet spider and also Database Concepts 4th edition book. But I am unable to understand the concept. Can anyone please explain it with proper example?
Super Key is used to identify all the records in a relation. Candidate key is a subset of Super Key. All super keys can't be candidate keys. All candidate keys are super keys.
A determinant can uniquely determine one or more attributes in the row. A candidate key can uniquely determine the entire row.
Candidate Key – is a set of attributes that uniquely identify tuples in a table. Candidate Key is a super key with no repeated attributes. Alternate Key – is a column or group of columns in a table that uniquely identify every row in that table.
Definition. A candidate key is a super key with no redundant attributes, while a composite key is a key that consists of two or more attributes that uniquely identify any row in the table. Thus, this is the main difference between candidate key and composite key.
Candidate key
is a super key
from which you cannot remove any fields.
For instance, a software release can be identified either by major/minor version, or by the build date (we assume nightly builds).
Storing date in three fields is not a good idea of course, but let's pretend it is for demonstration purposes:
year month date major minor 2008 01 13 0 1 2008 04 23 0 2 2009 11 05 1 0 2010 04 05 1 1
So (year, major, minor)
or (year, month, date, major)
are super keys (since they are unique) but not candidate keys, since you can remove year
or major
and the remaining set of columns will still be a super key.
(year, month, date)
and (major, minor)
are candidate keys, since you cannot remove any of the fields from them without breaking uniqueness.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With