10. Constraints and Indexes
This module combines integrity rules and indexing strategy so you can design schemas that are both safe and fast.
Design Matrix
| Need | Prefer |
|---|---|
| Unique row identity | PRIMARY KEY (usually surrogate identity) |
| Business uniqueness | UNIQUE constraint/index |
| Parent-child integrity | FOREIGN KEY + index the FK column |
| Domain/value control | NOT NULL, CHECK, DEFAULT |
| Fast lookups and joins | indexes (B-tree by default) |
Lessons
What's Next
- Continue to 11. Date and Time Functions