Interview Question

What is a candidate key?

Candidate keys are minimal unique row identifiers.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

A candidate key is a minimal set of attributes that can uniquely identify a row. • Minimal means no proper subset is also unique. • One candidate key is chosen as the primary key. • Other candidate keys can be enforced with UNIQUE and NOT NULL constraints.

💡 SQL Example

CREATE TABLE users (user_id integer PRIMARY KEY, email text UNIQUE NOT NULL);

Result

CREATE TABLE

⚡ Quick Revision

Candidate keys are minimal unique row identifiers.