4 ms·
Make your logged events invertible and get an undo/redo function for free. That's how I kill three to four birds with one stone.
by blattimwind 8y ago
Make your logged events invertible and get an undo/redo function for free. That's how I kill three to four birds with one stone.
- mamcx 8y agoinvertible? What is that?
- blattimwind 8y agoSay you record an event like "name of customer X has been changed to FooCo". Instead, record "name of customer X has been changed to FooCo from Foo & Sons Co". If you want to undo it, just swap from/to (=invert it).
- zbentley 8y agoA common pattern to implement this is an audit table: https://dba.stackexchange.com/questions/15186/what-is-an-audit-table https://dba.stackexchange.com/questions/15186/what-is-an-aud... ...which is itself a special case of an audit trail or log: https://en.wikipedia.org/wiki/Audit_trail https://en.wikipedia.org/wiki/Audit_trail
- blattimwind 8y agoIn my experience the usefulness of audit tables diminishes as the table becomes more complex (more columns; composite and document columns, like arrays, json, xml), because it becomes difficult to find what exactly changed. Another problem is related rows; audit tables aren't very good to capture the context of changes. You can work around this with more complex triggers, but it quickly becomes a lot easier to do this from the application and not in the database, capturing semantics and not just data changes. The issue with any application-based approach is of course that it can't provide total access mediation.