Constraints as Design

A constraint is a rule that survives everyone. Your application, a colleague's script, a migration, an admin action, and you at 2am. Only the database enforces all of them.

Postgres gives you more than SQLite: CHECK constraints spanning several columns, UNIQUE across a combination, partial unique indexes, and EXCLUDE constraints that can prevent two bookings overlapping in time.

◈ Graded Query

Find the data that a constraint should have prevented. Return the id and title of every workshop whose signup count exceeds its capacity, counting only signups that were not canceled. Two columns, ordered by id.

Checked against the rows your query returns. 1 visible and 3 hidden checks, some against data you cannot see.

loading editor…

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Practice Test →
← Back