Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between a superkey and a candidate key?

Tags:

database

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?

like image 491
Dinesh Kumar Avatar asked Dec 23 '10 14:12

Dinesh Kumar


People also ask

Is a candidate key a Superkey?

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.

What are the differences between determinant and candidate key?

A determinant can uniquely determine one or more attributes in the row. A candidate key can uniquely determine the entire row.

What is the difference between candidate key and alternate key?

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.

What is difference between composite and candidate key?

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.


1 Answers

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.

like image 68
Quassnoi Avatar answered Oct 29 '22 14:10

Quassnoi