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/
- 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.
- Create a new ItemContent record for each revision.
- Break the connection between the Item and the Previous ItemContent
- Create a new connection between Item and the Current ItemContent
- Create a new "previous state" connection between the Current ItemContent and the previous one.
- 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.
'content': 'This is my new content',
title: 'old title',
'content': 'old content'
title: 'older title',
'content': 'older content'
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.