Constraints are rules enforced at the database level so invalid data can never sneak in. For analysts, constraints are the reason you can trust the numbers in your reports — the database guarantees integrity before analysis even begins.
Key Points
- PRIMARY KEY: uniquely identifies every row; no NULLs, no duplicates
- FOREIGN KEY: links a row to a parent table, preserving referential integrity
- UNIQUE: no duplicate values allowed (e.g., email addresses)
- NOT NULL: the column must always have a value
- DEFAULT: fills in a value automatically when none is provided
- CHECK (MySQL 8.0+): validates conditions like salary > 0
.png)