Candidate Key

Candidate Key

« Back to Glossary Index
Visit Us
Follow Me

In the context of relational databases, a candidate key is a set of one or more fields (columns) that can uniquely identify a record in a table. This means that the values in this set of fields are unique across all records in the table, and no two records can have the same combination of values in these fields.

Candidate keys are a fundamental concept in the relational model on which relational databases are based, and they play a critical role in ensuring data integrity. They are used to establish relationships between tables in a database.

For example, consider a table of employees:


In this table, both EmployeeID and SSN (Social Security Number) could be considered candidate keys, because each of them uniquely identifies a record in the table.

A table may have multiple candidate keys, but one candidate key is specially selected as the primary key. The primary key is used as the main way to uniquely identify records in a table. In the example above, EmployeeID might be chosen as the primary key.

While all primary keys are candidate keys, not all candidate keys become primary keys. The remaining candidate keys, which are not chosen as the primary key, can be used as alternate keys or unique keys.

The choice of primary key from among the candidate keys can depend on a variety of factors, such as the stability of the field values (it’s undesirable to choose a field whose values change frequently), performance considerations, and the specific needs of the database application.

You may also like...