Data Modeling and revision history and autosaves

32 views
Skip to first unread message

chrismi...@gmail.com

unread,
Jun 21, 2015, 1:44:51 AM6/21/15
to orient-...@googlegroups.com
I am working on a preliminary data model for a new project that includes something similar to a CMS. My question is about how to best handle revision history of items and autosave drafts.

The scenario is pretty simple. I have an Item Class that extends V and has several standard properties (content, title, etc). The vertex also connects to several other vertices (created by User, tagged_as Tag, has_comment Comment, etc).

I need to be able to save revision history of (at least some) of the data in the Item. I can see two ways of doing this, the first seems a more graph-aware strategy:
(adapted from http://patrick.wagstrom.net/weblog/2011/09/22/graph-databases-and-revision-history/)
  1. Each Item to actually be connected to a "ItemContent" vertex or something similiar. This ItemContent would hold the properties and connections to the outside world.
  2. Create a new ItemContent record for each revision.
  3. Break the connection between the Item and the Previous ItemContent
  4. Create a new connection between Item and the Current ItemContent
  5. Create a new "previous state" connection between the Current ItemContent and the previous one.
  6. In this way, I have a line of snapshots down through time that maintain all their connections.

This seems a little convoluted to me, but I may just not be wrapping my head around Graph Database concepts fully. I also don't know how to constrain to, say, 10 revisions.


The other approach would be to have one document Item with a subdocument Revisions, and just push previous states into Revisions with a date/time. I lose my connection history this way, and I don't know that I like that. I don't know why I would need to do advance querying or traversals on previous revisions, but I would like to keep the option open unless there is a good reason not to.


Item {



   
'title': "Title',

   'content': 'This is my new content',

   'revisions': [

       {

           title: 'old title',

           'content': 'old content'

           'archived': date


       },

       {

           title: 'older title',

           'content': 'older content'

           'archived': olderdate


       }


   ]


}




The model becomes even more convoluted when thinking about autosaves for each item.


Is there a third option? Is the graph option too convoluted (potentially millions of items with at least 10 revisions each).


I really appreciate any thoughts or resources.

Reply all
Reply to author
Forward
0 new messages