Graph database modeling tools
Graph data modeling is the process in which a Neo4j user describes an arbitrary domain as a connected graph of nodes and relationships. From this description, a graph data model is designed to answer questions in the form of Cypher queries.
Describing a Domain
Consider the following description of the connection between two people: Sally and John.Two people, John and Sally, are friends. Both John and Sally have read the book, Graph Databases.
We can take this statement, identify components such as labels, nodes, and relationships, and use these to build our model.
The first entity that we’ll identify in our domain are the nodes.The fundamental units that form a graph are nodes and relationships. In Neo4j, both nodes and relationships can contain properties. Nodes are often used to represent entities, but depending on the domain relationships may be used for that purpose as well. Apart from properties and relationships, nodes can also be labeled with zero or more labels.
— 3.1 Nodes
We can identify nodes as entities with a unique conceptual identity. In this case, these entities are outlined below in bold.Two people, John and Sally, are friends. Both John and Sally have read the book, Graph Databases.
- Graph Databases
Now that we have an idea of what our nodes will be, we decide what labels (if any) to assign our nodes.A label is a named graph construct that is used to group nodes into sets. All nodes labeled with the same label belongs to the same set. Many database queries can work with these sets instead of the whole graph, making queries easier to write and more efficient. A node may be labeled with any number of labels, including none, making labels an optional addition to the graph.
— 3.4 Labels
First we’ll start by identifying the roles of objects (John, Sally, Graph Databases) mentioned in the statement. We know that this statement is about two different types of objects:Two people, John and Sally, are friends. Both John and Sally have read the book, Graph Databases.
Now that we have identified both our nodes and labels, we can assign the labels to the nodes they describe. For John and Sally we apply the role Person. For Graph Databases we apply the role book.
Further, we can identify the interactions between these subjects:
- John is a friend of Sally
- Sally is a of John
- John has read Graph Databases
- Sally has read Graph Databases
Now that we have described the kinds of things in our domain as nodes with their labels, we can connect the nodes together to describe their interactions.