An audit log you can actually ask questions of
· 4-minute read · Engineering · by Direct Softworks
Most audit tables answer "what changed". The questions people actually arrive with are "who decided this" and "what did it look like in March", and those need a different design.

Every system gets an audit log eventually, usually after an incident. Almost every one is built the same way, and almost every one fails the first real question asked of it.
The standard design: a table with the table name, the row id, the column, the old value, the new value, a user id and a timestamp. It is complete, it is cheap to write with a trigger, and it can reconstruct anything.
Then somebody asks "who approved the discount on that order" and you find yourself reading four hundred rows of column changes trying to infer an intention that was never recorded.
Changes are not events
The gap is that a column diff records a mechanism, and people ask about decisions.
"Approved the discount" is one decision. In the table it is: discount_pct 0 to 15, discount_reason null to text, status pending to approved, approved_by null to 12, updated_at changed. Five rows, no name for what happened, and reconstructing the name requires knowing which combination of columns constitutes an approval, which is knowledge that lives in the application and not in the log.
So the fix is not a better schema for diffs. It is to log the event as well:
event: order.discount_approved
actor: user 12 (Ana Popescu, sales lead)
subject: order 4471
at: 2026-03-14 11:42:07+02
payload: { from: 0, to: 15, reason: "matched competitor quote" }
Keep the column-level diffs too. They are the forensic layer and they answer questions the event vocabulary did not anticipate. But the events are the layer people can actually read, and the one that makes the log usable by somebody who is not a developer.
The rule of thumb: if a person would name it in a sentence, it should be an event.
Store the actor properly, and beware two id spaces
Two mistakes here, and the second one is nastier.
Store enough of the actor to survive: the id, and a snapshot of their name and role at the time. If you store only the id and join to a users table, a person who leaves and is deleted takes the meaning of every historical entry with them. A GDPR erasure request can do the same thing, legitimately.
The second mistake: systems often have more than one kind of actor. An internal user, a client logging into a portal, an API key, the nightly job. If they all write their id into one user_id column, that column is meaningless, because id 12 means a different person depending on which space it came from, and no query can tell.
Either separate columns per actor type, or a single column with an explicit type discriminator. We have had to unpick exactly this and it is not a pleasant migration, because there is no way to tell retroactively which id space an old row came from. It is the same lesson as storing the tax treatment rather than the rate: a column that has quietly become two different things cannot be repaired by looking at it.
Append only, and enforce it
An audit log that can be edited is not evidence, it is a suggestion.
Revoke UPDATE and DELETE on the table for the application's database user. The application inserts and reads, nothing else. This is a one-line grant and it converts the log from something you believe into something you can point at.
The correction path for a wrong entry is a compensating entry, never an edit. Same as accounting, for the same reason.
What actually gets asked
In our experience, four questions, and they should each be one query.
Everything about this record. The timeline of one order, one invoice, one client. This is by far the most common and it needs an index on subject.
Everything this person did. Usually during an incident, usually about a specific window.
Who has looked at this? Reads, not writes. Most logs record only mutations, and then somebody asks who accessed a client's data, which is exactly the question that matters under GDPR and exactly the one the log cannot answer. Read logging is expensive, so be selective: log reads of the things a regulator would ask about, not every page view.
What did this look like on a date? Reconstruction. Possible from diffs, painful without a periodic snapshot. If this question matters in your domain, store a full snapshot of the record alongside significant events rather than replaying six hundred diffs.
Retention, which is not optional
An audit log grows forever and contains personal data, which puts it in tension with itself: you want it for evidence, and you are not allowed to keep personal data indefinitely without a reason.
Decide a retention period per event class, write it down, and implement it as a job rather than an intention. Financial events usually have a statutory floor. Read logs can be much shorter. Pseudonymising the actor after the retention window, while keeping the event, is often the right compromise: you retain the shape of what happened and lose the person.
Do this at the start. Retro-fitting retention onto four years of audit data means deciding, retrospectively, what you were allowed to keep, which is a worse conversation than deciding it now.