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:

  1. AFaster joins between the two tables
  2. Borders and order_items stay the same size
  3. Corder_items rows are automatically indexed
  4. 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