1

I am considering the possibility of keeping history of all the data changes on a OrientDB database. This history shall be explorable just like the normal data. Like: I shall be able to query all the changes that a user have ever done to his profile.

I considered some solution like suggested here to create history classes for each vertex class and to create a history record for each update (vertex version increase) in that class whenever a vertex changes.

Can this be done directly inside DB using some kind of trigger like what Oracle has?

Even if that served for normal data of vertex what about edges? how could I preserve them in history? and between vertices?

I there a more straight forward way to do this in OrientDB?

Community
  • 1
  • 1
mohamnag
  • 2,709
  • 5
  • 27
  • 40

1 Answers1

1

I would suggest to keep the changes and the history in some kind of event store. This can be a sequence of events, each is immutable, records will be appended only.

This could look like

VERTEX_CREATED(id: 1337, time: 1336624823)
VERTEX_CHANGED(field: foo, before: A, after: B, time: 133676328)
...

This makes it possible to replay the history from any point you want, you can skip entries to supress errors which occured and so on.

If you store such records in a table or in a graph is not relevant. Inside a graph, this could be nodes, where each node is connected with the event before and after itself, like a linked list. In a table this would be only rows.

If you want to learn more about this approach, I can suggest you Event Sourcing by Martin Fowler.

Martin Seeler
  • 6,874
  • 3
  • 33
  • 45
  • in the past I have tried something like that by recording event logs, but that could potentially mean only to obtain status of one record on an specific time in the past, I have to replay an avalanche of events. doesn't it look like lots of processing? – mohamnag Oct 12 '15 at 14:31
  • You can also filter your events by a node ID and only revert or re-apply this subset. – Martin Seeler Oct 12 '15 at 14:50
  • 1
    I had to do a bunch of research around this and with every step it became more clear that this is actually a very good practice. one very inspiring talk I found here: https://www.youtube.com/watch?v=jO7ZVnsrPEk – mohamnag Nov 25 '15 at 18:50