History and Soft Deletion

Decide deliberately whether you need history. Most applications need it somewhere and model it nowhere, then discover the need after the data is gone.

The question: when this value changes, does anyone ever need to know what it was before? A price, an address, a permission, an order status: usually yes. A display name: usually no.

Soft deletion is a trade, not a free win. A deleted_at column keeps the row and marks it gone.

What it buys: recovery, audit, and referential integrity that does not break.

What it costs: every single query must now remember to exclude deleted rows, and the one that forgets is a data leak. Unique constraints stop working as intended, because a deleted row still occupies the name. And 'delete my data' from a user is not satisfied by a flag.

◈ Graded Query

Soft deletion means every query must remember. Return the title of each workshop and how many people are actually attending it, excluding canceled signups, including workshops nobody has signed up for. Ordered by title. Two columns.

Checked against the rows your query returns. 1 visible and 2 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