Implementing a bipartite graph in neo4j

I have a bi-directional graph of users and items. I want to implement this in neo4j. is there a way to distinguish between nodes? right now, the only difference is the value of the property:

node A properties: type=user, age=18, name=user123 node B properties: type=item, price=123, name=item1234 

and the graph request in cypher is as follows:

 -get all users: start n=node:node_auto_index('type:user') return n; start n=node:node_auto_index('age:*') return n; 

1: although there is an age property for each user, there is no need to specify the exact type of node, is it? Should I indicate it anyway?

2: second, since the type property is completely duplicated, would it be easier to create 1 specific node with the user of the property and one specific node with the property element rather than link all user nodes and all node nodes to their adequate root node?

3: is there any way in neo4j when creating a node to indicate its type is different from creating a node parameter type? (something like each group of nodes is stored in a different section in db, and therefore requesting or collecting a specific group requires just pointing to this area, not all nodes and checking the type parameter)

+4
source share
1 answer

Well, there is no golden rule. If you have many nodes of the same type, you can use and index, otherwise enter node well too. Depends on your usecase, as really large supernode slows down and is better handled as indexes.

If you know that you have a unique property of type node, then of course you can infer it from this property and skip the type property in your case.

+2
source

All Articles