Seeking model design suggestions to ensure immutability, full record of changes


(Snellad1) #1

I require the archival/immutable record in neo4j of all changes to nodes and relationships between nodes.
For example: 1) when properties of existing node(s) need modifying, and 2) when relationship(s) between existing nodes are changed

Here is what I've thought of so far, would love to hear any feedback / suggestions you may have;

Case 1 - node property change
Consider this: A House has a Room with windows and doors. (House)-[:HAS]->(Room)
In this example I need to change the number of doors from 1 to 2, and to have a record of the change.
My idea:

I would create a new node with updated properties; include MODIFIED_BY and PRECEDED_BY relationships; replace HAS to HAD; create HAS to new node.

How would you do it?

Next case - When you need to replace an object node with another, existing node

Let's say we have 2 houses, and both owners decide to swap and sell their houses to each other:

Therefore I would need to change house 10 OWNED_BY Bob, and 12 by Fred.
What's the best way to include the history of the change in this case?

Many thanks for your feedback!

(Stefan Armbruster) #2

There a very good blog post on that topic, see

(Snellad1) #3

Thank you! I had not seen this blog post before.