Title says it all, looking fo hints/pointer/examples...
This is database-related, and off-topic. Still, as this easily eats into the code/Perl realm when being implemented, I hope I get away with it. So fellow Perlmonks, in case anyone has tackled this before:

My database is basically one table that holds entities. Then, another table holding attributes, each attribute having its own id and a field that links it to the parent entity, then 'attribute value' and so forth. EAV.

Now, coming from a "relational mindset", I've got problems wrapping my head around how to do "snapshots" of how a view (= a rendition of the entity with all its attributes displayed) of one entity looked at a certain point in time. In order to be able to rollback, to diff, to document (audit?) the history of an entry (an entity) in my db.

I think one way of implementing this is to add some tracking of revisions to the attribute table (to what revision an attribute belongs). Roughly, what I can think of is:

  1. Add a revision field to attributes table, start counting at rev. one. On SELECT, constraint to only attributes having a certain revision (latest/specific rev.); when new attributes are added, all current/unchanged attribs get copied with incremented rev number plus the new attribute. CONS: code overhead in implementation, bloat in the attributes db; or ...
  2. Add two revision fields, revision_start, revision_end. On SELECT, constraint to attributes that are a superset range of the desired revision. When new attributes are added, the revision_end field on attributes that remain attached to the entity is incremented. CONS: even describing it is verbose, code probably a nightmare. PRO: no bloat in attributes.


When I want to track who created/updated/deleted an attribute, I think I have to add yet another table, a journal, to match attribute revisions with users - right?

Probably I'm overseeing a very simple approach, so please, somebody shed some light.

(I've already found these ruby gems (ehem...) with many implementations of versioning of so called Active Records. Is there something to be learned there? Is one of these implementations a good example of how to do it? ...do it well?)

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.