in reply to OT: Looking for good solutions to implement revision control with an EAV db model?

In my opinion, the second approach of having validity dates ("valid from", "valid to") is the better approach, because it allows you to easily time-limit changes. The queries for what is valid "now" are easily hidden in a view.

As an alternative approach, consider only keeping the current version in one table and the journal of changes in a secondary table. Reconstructing the old situation then consists of reading the data from the current table and reverting all changes to it from the journal, which is hard to get right. But if your concern is mostly auditing and review/selected rollback of the changes, a journal is much easier to handle in my experience.

You can set up such a journal either with database triggers (foolproof) or by copying the data in your program (less clutter in the journal, also allows for ephemeral information like "change reason", "change place in program" and "changing user", which the database doesn't necessarily know about.

  • Comment on Re: OT: Looking for good solutions to implement revision control with an EAV db model?

Replies are listed 'Best First'.
Re^2: OT: Looking for good solutions to implement revision control with an EAV db model?
by isync (Hermit) on Jun 24, 2014 at 13:45 UTC
    Thanks for pointing out triggers!

    So, ...a journal. (I hoped for a solution without it.) Actually, in one implementation, it's what I already use. Seems to be the easier method of computing things like a per-user "activity log".

    My challenge with such a journal so far has been: what's the best (actually working/usable) way to interlock eav-table and journal-table? (Suggestions welcome) As one usually has to track who did what, which attributes (attr id) are involved, what was attr name (in case attr name is user changeable), what was value, what are the new values. So rollbacks actually work. But I'm babbling... Probably that's why, apart from perfomance, many people hate EAV: for versioning, the traditional design offers the fuzzy feeling of having a rigid backlog of old version snapshots, ready to be unearthed at any time, diff'ed against any version... The table model is tempting. But then, there's the natural goodness of freely attributing stuff... I guess that's the ongoing struggle of NoSQL or things like BigTable where you can tweak and extend the column schema to the max. Arg! After babbling, now I'm even going into musing... anyway.

    Thank you, Corion!