Q3. What is a primary key?
A primary key uniquely identifies every row in a table. It's both UNIQUE and NOT NULL, there's at most one per table, and PostgreSQL automatically builds an index on it so lookups are fast.
A primary key can be a single column or several columns together (a composite key). Many teams use a generated identity column or a UUID as a surrogate key rather than relying on natural data.
CREATE TABLE employees (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name TEXT NOT NULL,
team TEXT
);Key point: The follow-up is often 'natural key or surrogate key?'. Have a one-line reason ready: surrogate keys stay stable when business data changes.