Reputation: 780
I have overheard discussion like "Should this be put into a ledger instead of an update?" I have some feeling that is has to do with record keeping, but I cannot fully understand what is a ledger. Searching both on stackoverflow and google runs into accounting related articles.
So my question is, what is a ledger when talking about database applications?
Upvotes: 2
Views: 217
Reputation: 103
A ledger usually refers to a collection of states through which an entity passed. The difference between an update and storing the data in a ledger is that when using update you don't have a history of all the updates performed on a certain entity.
The most common example for ledgers is indeed a banking model. You can better see the difference in the example below:
With updates, every time a client withdraws or deposits money, you just update the amount of money that client owns:
user_id | ammount
-----------------------------
26KRZT | 45
Having a ledger, you can keep the entire history of the transactions (and compute the amount based on the client's transactions)
user_id | operation | ammount
----------------------------------------------------
26KRZT | DEPOSIT | 25
26KRZT | DEPOSIT | 35
26KRZT | WITHDRAW | 15
Basically, a ledger stores data in the database as diffs (updates to the previous version of an entity) in order to be able to get a change history for a given entity.
Upvotes: 3