Best practice of Neo4j for specified case

Hi guys, im new at Neo4j. I want to know the best practices of this beautiful piece.
I'm in a dilemma about some topics;
For example, I have a model that I want to analyze for a certain problem. Should I set up my graph relationships the way I want to analyze it? Or should I just connect all the things I know? Yes, I may need these connections in the future but because I don't need them for now. Should I create my graphs specific to the things I want to analyze( like separate graph for each analysis)? Or should I collect what I know in a single graph? If I put them all together, would there be a performance issue for my needed analysis?
Thank you for time.

Just like anything in life, this is an iterative process. Try solving a single problem first, and create a specific graph for it. Once you have accomplished that, try to add new data to existing graph and try to solve new problems. See if there are any performance issues and maybe rethink the graph schema. Ideally, you would like to have all the data connected in a single graph, which allows you to do various analysis that would not be possible without it. Remember, go step by step and solve one problem at a time.

2 Likes

There are a few basic patterns to follow that will make your life easier down the road:

  • Relationships from (child)-[to]->(parent), or (many)-[to]->(one)
  • Label names descriptive of a single node of that label:
    • (:Person {name: "Bob"}) and (:People {group-name: "Matrix", people: ["Mouse", "Apoc", "Switch"]}), not (:People {name: "Joe"}).
  • Identities are key. If you can define a way to uniquely identify each node in your data, from your data source (csv, json, etc.), everything gets easier.
    • Define indices for those identity properties with CREATE INDEX
    • Import all data with MERGE (carefully), so you can re-run the same data without breaking anything.
      • MERGE (:Thing {id: 2})-[:REL]->(:Other {id: 9}) is not the same as MERGE (a:Thing {id: 2}) MERGE (b:Other {id: 9)) MERGE (a)-[:REL]->(b)