Search code examples
neo4jgraph-databasesdatamodel

store files in Neo4j : neostore.nodestore.db


I'm reading about Neo4j underlying infrastructure in it's book and I think I found a contradiction .Here In the text it is mentioned that :"The next four bytes represent the ID of the first relationship connected to the node, and the following four bytes represent the ID of the first property for the node" :enter image description here

but as you can see in the figure 6-4 :enter image description here if you look at the photo it is Nextrelid! which one is correct? and if we only store first relationship in the nodestore file, what happen to the other relationship?


Solution

  • From the point of view of the node, the next relationship id is the same thing as "the id of the first relationship connected to the node". They're different ways of describing the same thing.

    The pattern here is that relationships are stored as a chain. To iterate over all relationships, from the node, you use the id of the first relationship to jump to that relationship in memory, then jump to the area in memory on that relationship where the next rel id is stored and pointer chase across the rest of the chain.

    That said, when relationships reach a particular density (I think it's 50 rels per node) then the structure is somewhat different, a new entity is present between the node and its relationships to allow for more efficient navigation of its relationships.