I’m just thinking out loud here. I’d like to have the ability to store historical versions of each vertex and edge created from my domain model. I wondering how I might like to do it. At this point, I am more concerned with it being easy to use and reason about than I am with it being the most efficient implementation possible.
Use cases for this sort of functionality include being able to provide diffs showing changes, establishing audit trails, etc…
One possibility would be to create a mirror class for every class in the domain, e.g. a Person class with properties name and age would require a Person_historical class with the same properties + a property that indicating the @rid for the Person that is was a historical version of. Every time a Person vertex changed you would instantiate a Person_historical where the properties of the values where what the Person was before applying any updates. This is somewhat like the way we currently do things with RDBMS.
Another possibility that has occurred to me is that each vertex could essentially be connected to a chain of historical versions of itself. I think I’d create an Edge class with a property that captured the time that the change occurred and maybe another property to indicate whether the change was a deletion or an update (or something else?). So, a save of a Person would result in the creation of an additional person that was inserted between the itself and any existing historical versions of itself. *edit – This is not a great idea. The historical versions need to be some different class. Otherwise,
SELECT * FROM Foo would result in a mixture of results that represent both the current state of the application and the historical state.
Anyway, I was just wondering if anyone had done anything like this before with OrientDB (or any graph database). Maybe one of my ideas is a good place to begin? Maybe there is some existing functionality that I’m not yet aware of that I should take into account? Maybe there is a totally different and better way to do this?