After deleting a board, nobody could add a new one
Adding a site failed with a bare Validation error once any board had been deleted. A deleted board still held its code, and the error named nothing.
Topic
Schemas, constraints and keys, and the rules they are really enforcing.
35 articles
Most of the expensive bugs in an operational system are modelling decisions that were made quickly and then lived for years. Whether a balance is stored or derived, whether a soft delete has a defined answer for every child row, whether a foreign key is a business rule or a convenience — none of these announce themselves at the time, and all of them are discovered later by an accountant.
The recurring theme here is that a constraint is a claim about the world, and it is worth checking the claim before enforcing it. A check constraint that made over-delivery impossible to record did not stop lorries arriving with more than the order; it stopped the system being able to say so. That is worse than the problem it was written to prevent.
Adding a site failed with a bare Validation error once any board had been deleted. A deleted board still held its code, and the error named nothing.
A depot report showed nothing for an employee with 404 attendance records. A join that dropped anyone without a depot entry hid his whole history.
A region-wise notice reached 11 of the 500 people it was meant for. Two different lists of regions shared one name, and the form wrote one and read the other.
A manager's team screen showed 39 people, five of them deleted months earlier. 75 people across 60 leaders' teams were only half-deleted.
Office staff label each handover photo. Relabelling one removed the photo that held the label, and the next click failed six times in a row.
The report sent to advertisers shows two photos per board. If the close-up was taken first, it printed in the wide-shot slot. One field was doing three jobs.
A rewards scheme paid per attempt, so a retry was safe but a retake paid again. A flat price also made payouts grow with the quizzes added. Found in review.
A client kept board coordinates and bookings in two Excel files with no site code. Of 47 boards in both, 34 differed, by 4 m to 3,365 m. How we reconciled them.
A booking window ran to 5 September. On that day a dealer placing a first order was told it had closed. Every scheme the company had run had lost its last day.
A 184-obligation construction register was six weeks old when we found about a hundred entries may cite a law that had been replaced. Nothing in it could tell us.
A dealer-app product screen repeated every crop name 36 times and took 2.5 seconds to open. The table behind it mapped every product to every crop in every state.
A depot could not register a distributor because the phone number was taken. Nobody had it. An employee had been locked out for three months by the same mechanism.
WhatsApp confirmations to foreign customers were failing. The failures were the lucky cases: three messages with a UK customer's booking reached a stranger's phone.
The owner suspected the phone numbers were wrong. They were — 9,300 of them — and the check meant to prevent it had only ever tested one end.
Before building an AI assistant over an orders database, we found 2,667 approved orders it would have reported as cancelled, with no error.
Forty key columns moved to one ID format. Development ran a newer database than production, so the obvious fix would pass every test and fail on the live box.
In several countries an invoice series must be unbroken. A plain database counter leaves holes the moment a draft is abandoned. Here is what we built instead.
Most of what you can be inspected on is filings, notices and inspections, not certificates. A register of 184 obligations shows why that matters.
Some tax regimes make an invoice invalid until the government stamps it. Built naively, one slow afternoon at the regulator stops every till in your shop.
An auditor wants a record as it stood in March and who changed it since. Most systems only promise staff will not edit history. Ours makes the edit impossible.
A till refused to bill for no reason its owner could see. The invoice number came from a clock, repeated every 16 minutes and was shared with every other customer.
Stock was visibly running out and the low-stock screen showed nothing. The opposite failure, an alert on every order, comes from treating blank as zero.
In a children's learning app, removing a child left her tablet signed in, and adding her back made a blank copy with none of her history.
Stock software often splits one building into three locations. We describe a site by what it can do instead, and found a check that used the wrong rule.
Retiring a product left 211 orphaned prices and 104 orphaned variants, and half the stock rows pointed at nothing. Removal must never touch sales history.
A customer queries a line six weeks after the quote. The sheet rate has moved twice, the estimator is on site, and a price you cannot reconstruct is one you concede.
A stock system refused 100 kg received against a 90 kg order, so clerks edited the agreed order to get goods shelved. The rule was the fault.
Yield was recorded per batch, so a bad pass through the press was hidden. Recording output per run fixed that, but only from a date forward.
A promotion and every customer's free trial ended five and a half hours away from the time the business meant, because the software kept the wrong clock.
Composite keys stop a cross-tenant row being written; row-level security limits what is read. Two systems, and the gaps each one wrote down.
A child did one piece of work and was paid for it twice. A parent asked where the points went and nobody could answer. Why a total you can edit cannot be trusted.
About fifteen of a media owner's thirty-eight campaigns had no end date. Leaving the date blank would have quietly broken availability. What we did instead.
Every invoice had to sit on a booking. A partner's share, a supplier's mounting bill, an advance, a credit: real invoices with no booking could not be recorded.
Eighteen trips showed a driver who had been taken off, and on seven the removed driver could no longer be identified. The record kept for safety caused it.
A co-investor's profit share and an agency's commission both go out to a company each month. Added together, they give a total that means nothing.