Keys are only useful if the database actually enforces them. In this topic we move from identifying keys conceptually to declaring them as constraints that the database management system checks on every insert, update, and delete. PRIMARY KEY, FOREIGN KEY, and UNIQUE constraints are the mechanisms that turn a design decision on paper into a guarantee the data cannot violate.
You will look at why constraints matter for data integrity, how to declare them in CREATE TABLE and later add them with ALTER TABLE, how foreign keys protect referential integrity between related tables, and how UNIQUE enforces candidate keys that were not chosen as the primary key. You will also weigh composite natural keys against surrogate keys, and learn the practical side of constraint management: naming, adding, disabling, and dropping constraints without breaking existing data.
As you watch, pay attention to three things: the exact SQL syntax used (especially the CONSTRAINT name clause), what error the database raises when a constraint is violated, and what happens when you try to add a constraint to a table that already contains rows that would violate it. Those details are what separate working schemas from fragile ones.
An overview of SQL constraints framed around common interview questions, so it defines each constraint type and explains the role it plays in protecting data integrity. Expect coverage of the main constraint family, including PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, and DEFAULT, with the distinctions between them made explicit.
It is a good entry point for the subtopic on why key constraints matter, because the question-and-answer framing forces clear, short explanations of what each constraint actually guarantees.
This video focuses on the realistic case of a table that already exists and already holds data, then shows how to apply constraints to it after the fact. It should demonstrate ALTER TABLE syntax for attaching constraints and discuss what to do when existing rows conflict with the rule you are trying to impose.
Adding constraints to live tables is exactly the constraint-management subtopic, and this video addresses the practical obstacles that a CREATE TABLE-only treatment would never surface.
A short, example-driven walkthrough of ADD CONSTRAINT in SQL, with the companion operations for dropping and renaming constraints. Produced by CockroachDB, it keeps the focus on the statement syntax and on naming constraints so they can be referenced later.
Its brevity and concrete examples make it an efficient reference for the add, disable, and drop lifecycle, and the emphasis on named constraints reinforces a core best practice for consistent enforcement across a schema.
Together these videos reinforce the declarative half of the module. The constraints overview supports MO1 by tying each key type to the constraint that enforces it, and supports MO3 indirectly by clarifying how UNIQUE expresses a candidate key that is not the primary key. The two ALTER TABLE videos directly serve MO2, showing how PRIMARY KEY, FOREIGN KEY, and UNIQUE constraints are written both at table creation and afterward, and the foreign key discussion provides the syntactic foundation you will extend in MO5 when configuring ON DELETE and ON UPDATE actions. MO4 remains largely a design judgment you will practice in the module activities, but seeing how composite and single-column constraints are declared gives you a concrete sense of the trade-offs involved.
These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.