Database Testing / Quiz
Constraint Enforcement Division
Foreign keys, CASCADE vs RESTRICT, the multiple-NULLs-in-UNIQUE surprise, and why app-side validation alone is a promise, not a guarantee.
- Difficulty
- Medium
- Format
- Quiz
- Points
- 150
- Estimate
- 10 min
// MISSION BRIEF
Your Mission
Constraints are the database's own test suite, running on every write, forever. This quiz covers what each constraint actually guarantees, the NULL semantics that surprise even seniors, and why "the app validates it" is famous last words.
Scoring: timed quiz; accuracy first, speed bonus for fast clean runs.
// FIRST CONTACT
Battle teaser
A foreign key from order_items.order_id to orders.id guarantees:
- AFaster joins between the two tables
- Borders and order_items stay the same size
- Corder_items rows are automatically indexed
- DEvery non-NULL order_id references an existing order; inserts of dangling references and deletes that would orphan children are rejected (per the ON DELETE rule)
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
sqldatabase-testingconstraintsdata-integrity