I am working on a description of a tree dataset in Neo4j. In my current model, a node can have n links to other nodes, making them children of the node of these nodes:
root | \
- Root Links
- 1 and 2 link to A
- root is the parent of A
- 1 and 2 are children of A
Since I use nodejs (with node-neo4j ), reading the database is limited to using Cypher. To read the nodes, I use the following query:
START n=node(1)
My problem: this query becomes very slow (> 1 s) as the number of nodes and relationships increases.
Is there a better way to model nodes and relationships? Do I need different relationships between parent nodes and child nodes? Or should I somehow modify the request?
Thanks for any pointers!
1) The problem of the real world: This is a business process tool in which services are associated with processes, organizations, teams, etc., to provide information on what services are required, when and by whom, and also to provide information that will provide this service or is responsible.
So for example:
Service S is used in processes P1 and P2:
P1 P2 | | \---+-- S
Service S is controlled by the T command:
T | \-- S
Team T is part of O:
O | \-- T
Wood:
root | | +-- Processes | | | +-- P1 | | | | | \-- S | | | \-- P2 | | | | | \-- S | +-- Organisations | | | +-- O | | | \-- T | | | \-- S
2) My data in console.neo4j.org :
CREATE (r {name:'root'}), (ps {name: 'Processes'})-[:links]->r, (p1 {name: 'P1'})-[:links]->ps, (p2 {name: 'P2'})-[:links]->ps, (s {name: 'Service'})-[:links]->p1, s-[:links]->p2, (org {name: 'Organisations' })-[:links]->r, (t {name: 'Team'})-[:links]->org, s-[:links]->t