1
votes

I have an interesting situation. I am allowing users to provide their own data sources to be imported into neo4j. The data sources could be the same across different users, but I would like cypher queries to only query nodes and relations specified by a particular user's sources.

I can think of several ways to do this:

  1. Separate neo4j instances for each user
  2. Tag nodes and relationships by user

Currently node duplicates are prevented by indexes so I would have to alter that approach since nodes which already exist simply cause a new relationship to that node. Number of relationships to a node are used in my analysis so separating relationships by user are important.

I will have to update an existing graph database to account for these new attributes. I'm thinking that tagging relationships might be the way to go. Any thoughts pro/con against this approach? This way I can include the user tag as a relationship parameter.

Thoughts?

Henry

1
This doesn't really answer your question as you are interested in a cypher-based solution, but perhaps it provides inspiration. Multi-tenancy in graphs can be accomplished via TinkerPop's PartitionGraph: github.com/tinkerpop/blueprints/wiki/Partition-Implementation. You can read more about it here: thinkaurelius.com/2012/04/06/multitenant-graph-applicationsstephen mallette

1 Answers

2
votes

You can tag all your users with labels and use these even to tag the source:

http://docs.neo4j.org/chunked/preview/query-match.html#match-get-all-nodes-with-a-label