Creating relationship over several millions of nodes

That is very odd. There might be something off with your i.p1 data or index.

Relationship Direction

You're missing the direction on your :PRODUCES relationship:

(i)-[:PRODUCES]-(a)

Which leads me to three graph-data-design questions:

  • Which is the parent? :Inventory or :Product?
  • What will your queries be looking for?
  • Where's the "many" side of the relationship between i and p?

The answers to these questions should inform the directionality of the :PRODUCES relationship, because query performance starts with choosing either in or out relationships from initially selected nodes. When in doubt, point from many to few, or children to parents. For your case, I suspect you have many more Products than Inventory, and each Inventory item "produces" many different Products? If that is the case, you should consider (:Product)-[:PRODUCED_BY]->(:Inventory).

Code Standards Note: :Products shouldn't be plural unless each node represents many products.

Sorry, my bad. There were some issues with i.p1. I fixed it this morning and it's not hanging anymore!!

Your understanding is right. I have many more Products(~10-20M) that are PRODUCED_BY by Inventory nodes.
I am very new to Neo4j and I was reading a blog last week where they recommended to go with one -> many relationship so I chose Inventory -> Product.

  • Which is the parent? :Inventory or :Product ?
    Inventory. As I am planning to connect other node labels (Price, Owner, Location.. etc) with my Inventory as well.
  • What will your queries be looking for? My queries will start from the Inventory node and then it will pull all data connected to that inventory node.
  • Where's the "many" side of the relationship between i and p ?
    This is where I am getting confused a bit.I think I can go with either way right? In my case an Inventory node can produce many products. Similarly, same product can be produced by more than one Inventory node.

Could you link me, so I can go yell at them? :stuck_out_tongue_winking_eye:

Information Architecture, Entity Markup Language, Type Theory, Object Modeling, and many, many other notation systems which are inter-related all follow a standard rotational system of child --> parent or many --> one. For Neo4j and Cypher it doesn't matter much, as long as you stay consistent in your data and queries. However, in logic, object modeling, type theory, and information architecture (which can all inform or be informed by the graph) directionality can have significant impact.

1 Like

Obsessed! This really makes sense and thanks to all parties involved in deriving this solution.

1 Like