History must outlive what it records
Referential integrity and historical integrity are different requirements. When the subject is deleted, the first one dies with it, and the second is exactly what you needed.
Conditions · subject gone, receipt intact
The replacement worked. That is the problem.
A workspace had to be replaced, deleted and recreated during a recovery. The operation succeeded. The cascade did exactly what cascades are for: it swept the old entity’s missions, its tasks, every child row that belonged to the dead thing. Clean removal. No orphans. The kind of deletion that passes review.
It also deleted the records that would have proved the earlier attempt existed. The deduplication evidence. The recovery state. The audit trail that could have explained why the recovery was necessary in the first place. The system erased its own receipts as a side effect of cleaning up, and it did so correctly. Every foreign key behaved as designed, every cascade fired on schedule.
The cleanup deleted the evidence. But here is the thing, that sentence should not be possible, and in most schemas it is not merely possible but scheduled.
I have reviewed schemas like this one. I have nodded at the cascade declarations because they were tidy, and tidiness reads as correctness. The references all resolved. That was the whole examination, and it was examining the wrong property entirely. You have probably nodded at the same tidy lines.
Two kinds of integrity
The confusion starts with the word itself. A schema has integrity, we say, and we mean one thing by it: references resolve. Every pointer lands on a live row. The database is a faithful map of what currently exists.
That is referential integrity, and it serves the present tense. It answers: what can you navigate to, right now?
But some records do not exist to be navigated to. They exist to be believed later: audit rows, deduplication markers, recovery state, the history of attempts. Their value begins where the subject’s life ends. A receipt whose validity depends on the continued existence of the thing it receipts is not a receipt. It is a cache entry wearing archival language.
Once you name the split, the receipts stop looking like three separate lessons and start looking like one claim with three temporal skins.
Outliving the container
A finding’s routing lifecycle runs for weeks. Its investigation, a bounded mission with a resolution, runs for days. The mission closes; the finding still waits, routed to a patch release that has not shipped yet.
Put the lifecycle inside the mission and you get two bad options: the state dies when the mission resolves, or the mission stays artificially open because something living is trapped inside it. Both are the same error. A long-running thing nested in a short-lived thing, forced to share its schedule.
The fix is not subtle. When a lifecycle outlives its container, they become separate structures with separate state machines, and the container gets to resolve without taking the lifecycle with it. The design question is one sentence: does this outlive that?
Outliving the subject
Deletion is the harder case, because the mechanism that destroys your history is the mechanism your schema is proudest of.
A cascade encodes an answer: when the parent dies, the children die. For genuine children, rows that are meaningless apart from their parent, that answer is correct, and the receipts kept exactly those cascades. But an audit record is not a child of the thing it audits. It is a witness to it. And your schema cannot tell a witness from a child unless you mark the difference.
The marking is physical. References that cross into the replaceable chain stay plain identifiers: no foreign key, no cascade, no automatic death. Within the record’s own family, where children genuinely share its retention lifecycle, the cascades stay. And because conventions erode, the survival is not a convention at all. A failure-injection test deletes the subject and asserts the witness rows remain, dangling references intact. The invariant is enforced by a test that can fail, not by a comment that cannot.
The dangling identifier is the part that makes reviewers flinch, and it is the whole point. After the replacement, the identifier dangles, and its dangling is the evidence. It says: this happened, and the thing it happened to is gone. A receipt does not become false when the store burns down.
Outliving closure
The third survival is the quietest. Some of your records must not only survive deletion and container resolution. They must survive their own ending.
A terminal aggregate on a one-way-door state machine cannot reopen. Every further transition is refused; that is what terminal means. Then operations needs a retry. You cannot walk the door back, since reopening would break the contract everyone else relies on, and you cannot forbid the attempt either, because the work is still owed.
The answer is that the retry is not a second life for the record but a new entry in its history: appended, linked, the terminal state untouched. The original failure and the new attempt both persist. Nothing gets rewritten. The distinction between recorded and completed Referenced concept Recorded / Completed Recorded means the workflow has durable identity and re-entry is refused; completed means no required effect remains pending and no recovery is still owed. is what makes the append honest: the record keeps its ending, and the history keeps growing past it.
Closure is a fact about the subject. History has no obligation to share it.
The fork
Underneath all three exhibits sits a single unasked question. Every reference in your schema encodes an answer to it:
What happens when the target disappears?
Navigation references answer: the reference dies with the target. That is correct for children that share the parent’s retention lifecycle, the majority case, and the reason cascades exist.
Preservation references answer: the reference remains, and its dangling is the receipt. Audit, deduplication, recovery, cross-chain history: the records whose value is exactly that the subject is gone.
History that disappears with its subject is nested state wearing archival language.
The failure in every receipt was never a wrong answer. It was an unasked question, navigation semantics inherited by evidence because nobody declared which kind of reference this one was. The schema did not choose to erase the audit trail. It never chose anything, and the default chose for it.
Look at the last schema you wrote and count how many times you asked the question out loud.
The retention test
The operational form, for every historical or recovery record:
- What event, obligation, audit, or deduplication need gives this record value?
- Which live entities may be replaced or deleted before that value expires?
- Does the record’s storage survive independently of those entities?
- Can any cascade still reach across and erase it?
- Should a dangling identifier remain as evidence, rather than serve as current navigation?
Five questions, asked once per record, at design time. Cheaper than the recovery that answers them for you.
What this is not
The misreading is ready-made, so: no, foreign keys are not negligence, and cascades are not a smell. Reachability is the common case, and the tool that enforces it is the right default. The receipts kept real cascading keys everywhere the family genuinely shared a death. Preservation is the exception, and you argue for it per record, through the test above. You do not sprinkle it over the schema as a style.
The sharper objection deserves its paragraph: soft deletes and event logs already solve this. They solve a different problem. Soft delete keeps the subject alive and queryable; nothing dangles because nothing dies, and you pay for that with a permanent ghost population every query must filter. Event sourcing is a different architectural commitment entirely, not a decision about one reference. This piece is about ordinary systems that delete. Where deletion is real, the fork is real, and “use an event log” is not an answer to “which kind of reference is this.”
Somewhere in your schema there is a record whose entire purpose is to explain a failure, and whose life is coupled, by one tidy line, to the thing it would need to explain.
Find it before the recovery does. Ask the question the schema was never asked: when the target disappears, should this remain?
The black box is built to outlive the aircraft. Build your records that way where the future will need them, and let the rest cascade in peace.
History must outlive what it records.
More from this theme
The table was full
A stateful design that omits a reachable input does not stay neutral; the default branch decides. And a state table can enumerate every cell of the wrong axis and still read as complete.
Delete it and watch where complexity goes
Surface smell can put architecture on trial. Only a responsibility trace can tell you whether to delete, extract, preserve, or deliberately defer.