SQL Candidate Key

A Candidate Key is a column (or combination of columns) in a table that can uniquely identify each record in that table.
It is called candidate because it is a possible choice for the Primary Key
. From the candidate keys, one is selected as the Primary Key.

Key Characteristics of Candidate Key
1. Unique
   • Each value must be different for every row.
2. Cannot contain NULL values
3. Minimal
   • It should contain the minimum number of columns required to uniquely identify a record.
4. Multiple Candidate Keys can exist
   • But only one becomes the Primary Key.

Example:

CREATE TABLE Students (
    Student_ID INT PRIMARY KEY,
    Email VARCHAR(100) UNIQUE,
    Phone VARCHAR(15) UNIQUE,
    Name VARCHAR(50)
);

Explanation:

Student_ID → Primary Key
Email → Candidate Key
Phone → Candidate Key

Both Email and Phone must be unique.

Simple Definition
👉 A Candidate Key is any column that can uniquely identify a row in a table and can potentially become the Primary Key.


Topics