27 / 65 · 15 SQL & Database Testing · Constraint Testing← prev⊞ allnext →☰ Read as one page
4.2Types of Constraints
| Constraint | Purpose | What to Test |
|---|---|---|
| PRIMARY KEY | Unique row identifier | Insert duplicate PK should fail |
| FOREIGN KEY | References must point to existing rows | Insert with non-existent FK should fail |
| UNIQUE | No duplicate values | Duplicate email should return constraint violation |
| NOT NULL | Column must have a value | NULL for required field should fail |
| CHECK | Custom validation | CHECK (price >= 0) — negative price should fail |
| DEFAULT | Provides value when none specified | Verify default is applied when column is omitted |