Data Model¶
Graph¶
Neo4j uses a Graph data model.
- A Graph contains Nodes and Relationships.
- Nodes have Properties.
- Relationships organize the graph.
- Relationships have Properties.
- Relationships are directed links between nodes.
- Properties are key-value pairs where the key is a string.
- The values of Properties in Neo4j can have one of several Types
- Queries are done by Traversing the Graph navigating from one Node to another along a Path.
- Indexes look-up Nodes or Relationships.
Comparison¶
- A graph database transforms a RDBMS
- If one takes the stack of rows stored in RDBMS tables, separate the rows as individual nodes and keeps the relationships, the data becomes visible as a graph.
- A graph database creates relationsips in Column-Family
- A Column-Family database uses families to group rows.
- When stored in a graph the families can become hierarchical.
- A graph database navigates a document store
- A document store can be seen as a graph, by asking what is the relationship between a field of the document and the document ?
- A graph database elaborates a Key-Value store
- When the values have Keys themselves, the underlying structure is the one of a graph.
Internals¶
You don’t need to read this section if you are only interested in using Neo4j in an application.
But if you are curious about how Neo4j does the internal magic, you may find this interesting.
The internal storage of Neo4j uses a double-linked-list data structure.
The content of these data structures is stored the following collection of files:
- /var/lib/neo4j/data/graph.db/neostore
- /var/lib/neo4j/data/graph.db/neostore.id
- /var/lib/neo4j/data/graph.db/neostore.nodestore.db
- /var/lib/neo4j/data/graph.db/neostore.nodestore.db.id
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.arrays
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.arrays.id
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.id
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.index
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.index.id
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.index.keys
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.index.keys.id
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.strings
- /var/lib/neo4j/data/graph.db/neostore.propertystore.db.strings.id
- /var/lib/neo4j/data/graph.db/neostore.relationshipstore.db
- /var/lib/neo4j/data/graph.db/neostore.relationshipstore.db.id
- /var/lib/neo4j/data/graph.db/neostore.relationshiptypestore.db
- /var/lib/neo4j/data/graph.db/neostore.relationshiptypestore.db.id
- /var/lib/neo4j/data/graph.db/neostore.relationshiptypestore.db.names
- /var/lib/neo4j/data/graph.db/neostore.relationshiptypestore.db.names.id
The filenames are self-descriptive of their content.