Skip to main content

Versioning in graph databases

I got a question from one of my teams last week on how to apply versioning in Graph databases. There are multiple ways to tackle this problem but let me share the way I typically handle this.

What do you mean with ‘versioning’?

Let me start by explaining what I mean exactly with ‘versioning’.  Our data changes over time. Without versioning we only now the current state of our data but not what happened in the past. By applying versioning techniques, we can keep track of changes both on the data and its dependencies. This can be useful for auditing purposes but there are a lot more reasons why this can be applied.

There are multiple types of versioning but the question I got was related to time-based versioning. The idea with time-based versioning is that you can track changes over time. We end up with an append-only model where we are able to step through time to understand the state changes.

How to model time-based versioning in graph databases?

The core idea with time-based versioning in graph databases is to separate the entity from its state. We create a separate node for the entity itself and for its state. We track the time this state was applicable through the relationship between both entity and state node.

Separate object from state

Let me further explain this by giving a small example. We start with a simple Order node with a few properties.

What if we want to track the changes of the order over time? Let us separate the Order entity from the OrderState:

Now we can use the relationship to have time-based versioning. Nice!

Want to learn more?

If you want to learn more about this and other techniques, check out the following youtube video:

Popular posts from this blog

XUnit - Assert.Collection

A colleague asked me to take a look at the following code inside a test project: My first guess would be that this code checks that the specified condition(the contains) is true for every element in the list.  This turns out not to be the case. The Assert.Collection expects a list of element inspectors, one for every item in the list. The first inspector is used to check the first item, the second inspector the second item and so on. The number of inspectors should match the number of elements in the list. An example: The behavior I expected could be achieved using the Assert.All method:

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

Angular --deploy-url and --base-href

As long you are running your Angular application at a root URL (e.g. ) you don’t need to worry that much about either the ‘--deploy-url’ and ‘--base-href’ parameters. But once you want to serve your Angular application from a server sub folder(e.g. ) these parameters become important. --base-href If you deploy your Angular app to a subfolder, the ‘--base-href’ is important to generate the correct routes. This parameter will update the <base href> tag inside the index.html. For example, if the index.html is on the server at /angularapp/index.html , the base href should be set to <base href="/angularapp/"> . More information: --deploy-url A second parameter that is important is ‘--deploy-url’. This parameter will update the generated url’s for our assets(scripts, css) inside the index.html. To make your assets available at /angularapp/, the deploy url should