design-patternsneo4jgraph-databasestemporal-databasedata-masking

Temporal Neo4J database for "data masking"


I'm evaluating databases for a project. Right now I'm strongly preferring Neo4J for it's graph nature.

I'm looking to create a temporal database that uses something like a "last good value" approach (my words).

Here's an example using a rough Neo4J pseudo-code. Imagine the following happening as separate transactions.

CREATE (a:Person {first: "Charles", last: "Tolliver", timestamp: timestamp() + 00})
CREATE (b:Person {first: "Charlie",                   timestamp: timestamp() + 10})
CREATE (c:Person {first: "Chuck",                     timestamp: timestamp() + 20})
CREATE (d:Person {                  last: "Peters",   timestamp: timestamp() + 30})
CREATE (e:Person {age:42,                             timestamp: timestamp() + 40})

CREATE (a)<-[:UPDATES]-(b)<-[:UPDATES]-(c)<-[:UPDATES]-(d)<-[:UPDATES]-(e)
RETURN a,b,c,d,e;

Then I want to be able to do something like:

MATCH (p:Person)
WHERE p.first="Charles"
return p, collect( 
  { first: p.first, last: p.last, age: p.age, timestamp: p.timestamp }
)

I would like to get data back like this:

{ first: "Chuck", last: "Peters, age: 42, timestamp:...}

Where each subsequent insert "masks" the prior data.

Ideally I'd like to be able to query in the same manner with a variety of timestamps and get "snapshot" of the aggregate object at that point in time.

Questions:

*Note: For various reasons, I prefer not to use a 'frame'-based temporality.

Note: I am not asking "Which databases are 'best' for this" or anything subjective. I'm looking for objective info about support for this pattern/paradigm.


Solution

  • I ended up going with Datomic because of the built-in temporality. I'm enjoying it a lot (especially Datalog, it's query language). I do wish it had more practical documentation, though.