0Pricing
SQL Interview Prep · Lesson

Primary Keys, Foreign Keys and Constraints

Explain keys, uniqueness, and referential integrity the way an interviewer wants to hear it.

Why Keys Come Up Every Time

After defining SQL, interviewers turn to keys and constraints. The theme tying them together is integrity: rules the database enforces so bad data can't get in.

What a Primary Key Is

A primary key uniquely identifies each row. It's always unique and NOT NULL, and a table has at most one. Say it cleanly to score points.

CREATE TABLE customers (
  id INTEGER PRIMARY KEY,
  email VARCHAR(255) NOT NULL,
  name VARCHAR(100)
);

All lessons in this course

  1. What Is SQL and Why Interviewers Ask It
  2. Logical Query Execution Order
  3. Primary Keys, Foreign Keys and Constraints
  4. Reading a Schema Under Pressure
← Back to SQL Interview Prep