| [Relational Theory] | [Carol's HomePage] |
![]()
![]()
| Candidate Key | An attribute or group of attributes capable of acting as primary key. |
| Candidate key | A superkey such that no proper subset is a superkey within the relation. |
Let R be a relation. Then a candidate key for R is a subset of the attributes of R, say K, such that:
Uniqueness property:
No two distinct tuples of R have the same value
for K.
Irreducibility property:
No proper subset of K has the uniqueness
property.
A candidate key is a minimal subset of attributes in a relation which uniquely identifies each tuple in the relation.
If a relation schema has more than one key, each is called a candidate key.
If a relation has several keys, they are referred to as candidate keys.
The various keys of a relation are often known as candidate keys; the name implies a selection process whereby one of the candidate keys will be designated as the primary key.
A candidate key can be described as a superkey without redundancies.
In the relational model a candidate key of a relation is a set of attributes of that relation such that (1) in all instances of that relation it holds that there are no two distinct tuples with the same values for these attributes and (2) there is not a proper subset for which (1) holds. Since a superkey is defined as a set of attributes for which (1) holds we can also define candidate keys as minimal superkeys, i.e., superkeys of which no proper subset is also a superkey.
![]()
Every relation (table) has at least one candidate key; this must be the case since duplicate tuples (rows) are not allowed.
The importance of candidate keys is that they tell us how we can identify individual tuples in instances of a relation. As such they are one of the most important types of database constraints that should be specified when designing a database schema. Since an instance of a relation is always a set it holds that every relation will have at least one candidate key. Since in some RDBMSs tables may also represent multisets (which strictly means these DBMSs are not relational) it is an important design-rule to specify explicitly at least one candidate key for each relation. For practical reasons RDBMSs usually require that for each relation one of its candidate keys is declared as the primary key, which means that it is considered as the preferred way to identify individual tuples. Foreign keys, for example, are usually required to reference such a primary key and not in any other of the candidate keys.
![]()
|
URL: http://leven.cis.utas.edu.au/users/cae/my_websites/theory/CandidateKeys.shtml
Last modified: 13 November 2007 15:57:07 EST |