3 ms·
> There are auditing solutions to record all that, but the ones I know are (rightly) not really designed for building application logic on top of. Yes, a big p
by mason55 11y ago
> There are auditing solutions to record all that, but the ones I know are (rightly) not really designed for building application logic on top of.
Yes, a big problem with table-level audits is that you lose all kinds of information about the other entities in the system. Sure, now you have an audit log of when a row was changed, but you don't really know anything about the state of all the other pieces of the database at that time, so you can't really usefully reconstruct what the entity looked like at the time it was modified.
In theory you could parse through the whole audit log to reconstruct the state of the DB but in practice it gets very complicated.
- bmh100 11y agoA better solution is to perform row-level snapshots with a compressed storage format, such as a column store. I maintain a database which takes monthly snapshots of data and supports an application that allows period vs. period comparisons of aggregates or even individual rows. In my case, I use snapshots, but more space efficient (at the cost of computation) would be to only store changed records, then dynamically determine which data to show based on the desired periods and sorted the row changes.
- pjungwir 11y agoI think what mason had in mind, which I agree is a major pain point, is when a central table "owns" records in other tables, e.g. a `book` might have several rows in `pages`. I want to say "give me edition 3" and get not just the book at that point but all its pages too. Tracking changes to the book is not so hard, but reconstructing it with all its child records is a pain.
- mason55 11y agoYes exactly. Piecing together the state of all the foreign tables across the system at a specific point in time is difficult/painful. This is one place where document stores really shine as you generally keep everything in a single place. When you update a document you don't have to worry about the values of all the foreign keys, you just save the current version which contains all your values.