Write the schema.Let the tests decide.

Answer a business scenario with DDL. Hidden tests run it under the surface, on a real Postgres.

From a scenario to a verdict.

One exercise, soft deletes, the way you would meet it: read, answer, and find out what your design cannot hold.

Three departments, one table.

Every exercise starts as a business whose rules pull against each other. Here, Support, Finance and Growth each mean something different by delete.

No single right answer. Several designs hold; most do not.

soft-delete-without-breaking-signups

Three departments disagree about what delete means.

  • Supportcan restore an account for 30 days
  • Financekeeps the record forever: invoices point at it
  • Growthwants the email free for a new sign-up, now

A few names are fixed. The design is yours.

The tests read the names in the contract and nothing else. The types, keys, constraints and indexes around them are what is being assessed.

The contract is checked before any test runs, so a missing column says so instead of failing somewhere in the middle.

contract

users

  • idthe tests read this
  • emailthe tests read this
  • deleted_atthe tests read this

+ your types, keys, constraints, indexes

Write the schema you believe in.

Plain DDL, in an editor that behaves like one. Two different schemas can both be right: the battery grades what the design does, never what it is called.

Tab indents, Enter keeps the indent. Nothing to install.

answer.sql
CREATE TABLE users (
  id         BIGINT GENERATED ALWAYS AS IDENTITY,
  email      TEXT NOT NULL UNIQUE,
  deleted_at TIMESTAMPTZ
);

The first answer most people write. It looks right on a diagram.

Hidden tests, on a real Postgres.

The battery answers in about 40ms and names the rule your design cannot hold. Here, a plain UNIQUE cannot tell a deleted row from a live one.

Signed in, you also get a written review of your naming, types and trade-offs.

Try this one, it is free
battery · 3/4
  • PASSa signup is accepted
  • PASStwo live accounts cannot share an email
  • PASSa soft-deleted account keeps its address
  • FAILthe address can be reused after deletion

UNIQUE on the column applies to the dead row too. The fix is one line.

Practising queries is crowded. Practising the design under them is not, and the design is the part that ages badly.

22 problems where the obvious schema breaks.

Six tracks, in the order worth learning. 2 of them are free and need no account.

Everything you need to start is free.
No account.