31 / 65 · 15 SQL & Database Testing · Constraint Testing← prev⊞ allnext →☰ Read as one page
4.6Practical Exercise
- Write tests for each constraint type on a users table: PK, FK, UNIQUE, NOT NULL, CHECK
- Test CASCADE vs RESTRICT behavior on a foreign key
- Test default values: verify defaults are applied when columns are omitted
- Query the database to discover all constraints on a table, then write tests for each
- Test a case-sensitivity edge case on a unique constraint