DurkoMatko
DurkoMatko

Reputation: 5854

Edges (relationships) available only for specific users

I'm trying to create a model which allows users to navigate between positions (nodes) using various techniques (edges). Basically to traverse the positions graph using their own specific edges, which are unique and available just for them.

I want every user to be able to create their own edges(techniques) between nodes (positions). I've considered having technique edges to all have the same name/type - something like "LEADS_TO", but their properties will be different (name, description and most importantly, reference to user who is allowed to use the edge - basically a creator of that edge).

enter image description here

This means that during graph traversal, I'll have to filter only edges which have the the createdBy property matching with the userId. Also, this model expects that if there will be 1000 users using the app, there will likely be 1000 unique edges (techniques) between 2 nodes (positions).

Would this be correct approach or is my graph thinking/understanding conceptually wrong? Thanks!

Upvotes: 0

Views: 32

Answers (1)

logisima
logisima

Reputation: 7478

There are 3 ways to do what you want :

  • an edge with a property user_id that is a string. So like you said you will have multiple edges between your nodes pos1 & pos2 (on for each user)
  • an edge with a property user_id that is an array of string. So you will have one edge between your nodes pos1 & pos2, but the size of the array will match the number of user
  • prefix each edge's type with the user_id : USER_2_LEADS_TO

The choice depends on the type of your queries and also on hte volumetry, ie the average number of relationship you will have between your nodes pos1 & pos2.

As a first approach, your choice is good.

Cheers

Upvotes: 1

Related Questions