Describe a PRIMARY KEY and how it differs from a UNIQUE key

SQL
Medium
148K views

This question probes the nuances of identification constraints. It tests deep understanding of database rules.

Why Interviewers Ask This

It distinguishes between basic uniqueness and strict identity. Interviewers check if you know that a primary key implies NOT NULL and is unique per table. This is crucial for designing robust schemas.

How to Answer This Question

Define PRIMARY KEY as UNIQUE plus NOT NULL. State there can only be one per table. Contrast with UNIQUE which allows NULLs and permits multiple constraints. Mention foreign key dependencies.

Key Points to Cover

  • Primary Key is NOT NULL
  • Only one Primary Key allowed
  • Unique allows NULLs
  • Foreign Keys reference Primary Key

Sample Answer

A PRIMARY KEY uniquely identifies each row and combines UNIQUE with NOT NULL. There can be only one primary key per table, though it can span multiple columns. A UNIQUE key enforces uniqueness but allows NULL values and you can have many UNIQUE constraints per table.

Common Mistakes to Avoid

  • Thinking Unique cannot have NULLs
  • Believing multiple Primary Keys are allowed
  • Ignoring the NOT NULL requirement

Practice This Question with AI

Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.

Start Practicing

Related Interview Questions

Browse all 49 SQL questions