Append-only Ledger
Also known as: append-only log, immutable ledger.
A record store that only ever adds rows: corrections are new rows that point at the ones they replace, so history, including the mistake, stays readable.
Synthetic dataExamples on this page use synthetic data created for illustration.
Definition
An append-only ledger stores records by adding new rows only, never editing or deleting old ones. A correction is written as a new record that points to the one it replaces, so the full history, including the mistake, stays readable and every past state can be reconstructed.
In plain terms
Bookkeepers do not erase an entry in a ledger; they add a correcting entry. The same idea protects data. If rows can be overwritten, you can no longer say what the table contained last Tuesday, and any result computed from it cannot be reproduced.
The current state is simply a view over the ledger: for each item, the latest record that has not been replaced. Asking about the past means choosing an earlier cut-off.
Example
One price, recorded twice:
| id | item | price | recorded on | replaces |
|---|---|---|---|---|
| 1 | order-17 | 19.99 | Mar 1 | — |
| 2 | order-17 | 18.99 | Mar 9 | 1 |
Asked “what was the price as of Mar 5?”, the ledger answers 19.99. Asked now, it answers 18.99. Asked for the history, it returns both rows. An overwritten table could only ever give 18.99.
Common misunderstandings
- “Nothing can ever be removed.” Legal or safety reasons may require erasure; the ledger then records that a removal happened, and the process for it is designed in advance.
- “It is just an audit log.” An audit log sits beside the data; in a ledger the records themselves are the data.
- “It will grow without limit.” It grows, but old, replaced rows can be archived or summarised by a documented rule without changing what the past showed.
References
- Martin Kleppmann. Designing Data-Intensive Applications . O'Reilly Media, 2017. ISBN 978-1449373320.
- Martin Fowler. Event Sourcing . martinfowler.com, 2005.