I am looking for a suitable process by which to keep revisions, or snapshots of rows (and their relations) in a database.
Take for example an eCommerce platform-
I have looked at a few concepts, one being duplicate tables, another being temporal databases, and the other being keeping a revision id and active flag.
Whilst I appreciate no one can really tell me the best/most suitable solution for my application as it's a matter open to opinion etc, I was hoping that someone might be able to demonstrate the advantages/disadvantages possibly by way of comparison. I have read lots of questions on SO, and a fair few articles on the various implementations, but none really compare each idea or indicate where they'd be best suited. Below I have outlined my understanding of each of the concepts.
Store the information in rows relevant to the data with which they need to be snapshot with. I.e. Keep an address in columns in the orders table of an online store.
Database rows which are "time-aware", i.e. their context is the time between two datetimes. Data can be joined where it's time context lies between that of the temporal table.
Have a table which keeps track of changes to all tables and note the row it relates to and when it is valid in terms of time.
I have already looked at the following questions here on SO, and these other resources
Edit: The reason I haven't tagged this post with a particular DBMS as I'd like the concept to work with as many as possible ideally as the platform, at present is DBMS independent and the abstraction layer allows it to work with MySQL and MSSQL but will hopefully support others in the future.
A database snapshot is a read-only, static view of a SQL Server database (the source database). The database snapshot is transactionally consistent with the source database as of the moment of the snapshot's creation. A database snapshot always resides on the same server instance as its source database.
The two are very different techniques and from a performance perspective, a snapshot is created much faster than a backup/restore, but that is because it does not contain any real data when you first create it. Changes to the data pages are written to sparse file only when there is an update on the source database.
I ended up using a temporal database, and the implementation of this resulted in the Temporal Model in FuelPHP.
I can now configure my models to treat rows as a time sensitive entity. Changes cause a new row to be created and the end time of the original row set accordingly.
This allows me to retrieve a row at a point in time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With