attribute value history

55 views
Skip to first unread message

swami....@ishafoundation.org

unread,
Aug 3, 2015, 2:20:18 PM8/3/15
to OrientDB
Hi,

For certain classes in our database we need to store a history of each changed field value.

We are considering two possible structures for this:

1. using a key-value index, with entries of the form
id.attribute_name.counter = { "field": "name", "old_value": "jon", "new_value": "john", "datetime_modified" : "some-date", "modified_by": "some-user" }
where id is the unique id of the record, and counter is just an incremented integer

2. using the graph structure, and having "delta" nodes connected to the main node, with a "modification" edge, and the same json object (+ the attribute name) stored in this node 

The history info will sometimes be used to decide whether or not to update a record with new info

Would like to know pros/cons of both approaches

Kind Regards

Swami Kevala 

alessand...@gmail.com

unread,
Aug 4, 2015, 8:27:42 AM8/4/15
to OrientDB
Hi,
I think that if you have a lot of information to be stored in your node might be much better then having "delta" nodes connected to the main node,
otherwise if you have to keep in memory one field you could use a embeddedlist and add the old values time to time.
Regards,
Alessandro

Luca Garulli

unread,
Aug 4, 2015, 8:23:11 PM8/4/15
to OrientDB
We saw that most of the times, the best way is:
  • creating a new document/vertex per version, with inside all the changed fields
  • keep the same document/vertex as the last version, so all the pointers are still valid because the RID doesn't change
  • don't connect all the versions to the main document/vertex, but rather use a linked list approach where you connect all the versions with "previous" link/edge. Example: (#13:13 Company v.20)--prev-->(#14:22 Company v.19)--prev-->(#14:31 Company v.18)


Best Regards,

Luca Garulli
Founder & CEO


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Athanassios Hatzis

unread,
Aug 4, 2015, 9:17:18 PM8/4/15
to OrientDB
Incidentally the procedure that Luca described is very similar to what has been designed in Freebase

"Graphd is a log-structured or append-only store. To “modify” a primitive, for example by changing the value, you write a new primitive carrying
the modification and use the prev to indicate that it replaces the “modified” primitive."

A Brief Tour of GraphD by Scott Meyer
Reply all
Reply to author
Forward
0 new messages