Gremlin Query to give all related items in versioned graph

I am working on a requirement where I need to store all version of a record in a Graph Database say JanusGraph, one naïve approach for this requirement could be to create separate vertex for each record version. Say: Record R1 has version v1, v2, v3 Then create separate vertex for R1: v1, R2:v2 and R2:v3 But as the record updated multiple times so a Record could have thousands of versions and Graph will become very huge with this kind of approach. To overcome the above limitation, I am working on another approach to create only one vertex for a Record in Graph database and use HashMap as Edge property to store the version information. Suppose Record R1 version v1 is related to Record R2 version v1, Record R3 version v2 And Record R2 version v2 is related to Record R2 version v3, Record R3 version v4 For this I am creating an edge property as versionMap which is java.util.HashMap to store the version information R1 to R2 Edge property contains {v1: v2, v2: v3} that means R1: v1 is related to R2:v2 and R1:v2 is related to R2:v3 So, based on above the Graph could be like this. Vertex R1, R2, R3, R4 R1-R2 Edge Properties {v1: v2, v2: v3} R1-R3 Edge Properties {v1:v4, v2: v6} R2-R4 Edge Properties {v1:v7, v2: v8, v3:v9} So given the query give me all related records for Record R1 and version v1, I require to write a gremlin query that will return the relationships like this for multiple hops Relationships R1:v1 = R1:v1 -> R2:v2 ->R4:v8, Is this possible to use the versionMap through Gremlin Query and give the results in above format? Please Suggest
7 Replies
spmallette
spmallette2y ago
I'm not sure if this is helpful but you might consider looking at ChronoGraph which is designed to handle graph versioning use cases: https://github.com/Txture/chronos/tree/master/org.chronos.chronograph The creator of ChronoGraph just did a talk on the TinkerPop Twitch stream about it a couple of weeks ago: https://www.youtube.com/watch?v=WSGI-MMNRvM It's a neat TinkerPop implementation for a highly specialized need.
GitHub
chronos/org.chronos.chronograph at master · Txture/chronos
Embedded versioned persistence for JDK projects. Contribute to Txture/chronos development by creating an account on GitHub.
Apache TinkerPop
YouTube
TinkerPop Wide: Back to the Future - Time Travelling with Gremlin i...
Apache TinkerPop™ is a graph computing framework for graph systems and the home of the Gremlin graph traversal language. TinkerPop Wide streams offer an opportunity to hear from the wider community on their experiences with TinkerPop or graphs in their building of libraries, tools, graph systems or other applications. For this session: Database...
Akhan
AkhanOP2y ago
Thank you, I will go over this post 🙂
kelvinl2816
kelvinl28162y ago
I just saw this question. I recently added a comment to the SO post on the same topic. https://stackoverflow.com/questions/75844887/best-way-to-store-multiple-versions-of-a-record-in-graph-database-say-janusgraph
Stack Overflow
Best way to store multiple versions of a record in Graph Database s...
Suppose there are multiple versions of a record A say v1, v2,v3 and vn, and A is related to B till version v2 and A is related to C from version v3 Suppose A represent the record Id and vi represen...
kelvinl2816
kelvinl28162y ago
For version control systems like this, will you have any kind of TTL in place or will the graph never shrink?
Akhan
AkhanOP2y ago
Thanks Kelvin, the Graph will never shrink and it should be able to store millions of nodes, currently using Janusgraph backed by Azure Managed Cassandra for the same, so just thinking of saving the storage cost by avoiding multiple vertices for the same record 🙂
kelvinl2816
kelvinl28162y ago
Just to clarify one point - when you say "record" is that equivalent to a vertex and all of its properties (like a row in a relational table) or is it referring to just one property (like a column in a table). I'm just trying to picture the data model. To help the discussion a bit (hopefully) have you been thinking along these lines (just some examples of how this could be modeled) ?
Akhan
AkhanOP2y ago
Yes Kelvin, it is correct, a record is equivalent to a vertex and all of its properties, just like a row in RDBMS system, a record has different properties, the above example is showing it correctly, but we require to maintain all versions with relationships for those versions, like record 1 version 1 is related to record 2 version 2, record 1 version 3 could be related to record 2 version 3 and so on, so we need to preserve these kind of versioned relationships
Want results from more Discord servers?
Add your server