postgresql - Ways to implement data versioning in PostreSQL -
can share thoughts how implement data versioning in postgresql. (i've asked similar question regarding cassandra , mongodb. if have thoughts db better please share)
suppose need version records in simple address book. address book records stored in 1 table without relations simplicity. expect history:
- will used infrequently
- will used @ once present in "time machine" fashion
- there won't more versions few hundred single record.
- history won't expire.
i'm considering following approaches:
create new object table store history of records copy of schema of addressbook table , add timestamp , foreign key address book table.
create kind of schema less table store changes address book records. such table consist of: addressbookid, timestamp, fieldname, value. way store changes records , wouldn't have keep history table , address book table in sync.
create table store seralized (json) address book records or changes address book records. such table looks follows: addressbookid, timestamp, object (varchar). again schema less wouldn't have keep history table address book table in sync. (this modelled after simple document versioning couchdb)
i second approach: have table actual working set , history changes (timestamp, record_id, property_id, property_value). includes creation of records. third table describes properties (id, property_name, property_type), helps in data conversion higher in application. can track changes of single properties.
instead of timestamp have int-like, wich increment every change per record_id, have actual version.
Comments
Post a Comment