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 peopleJohn and Sally, are friends. Both John and Sally have read the bookGraph Databases.

We can take this statement, identify components such as labels, nodes, and relationships, and use these to build our model.

Draw the Data Model

Now that we have identified the kinds of relationships that can exist between labels of nodes, we can complete our graph data model.

Graph data model

Answering Questions

We have gone through the process of creating a basic graph data model for the interactions between people and books. We can take this data model further by defining attributes of these entities as key-value properties.

List your Questions

First, start by listing your questions that you want to answer about your data.

When did John and Sally become friends? What is the average rating of the book Graph Databases? Who is the author of the book Graph Databases? How old is Sally? How old is John? Who is older, Sally or John? Who read the book Graph Databases first, Sally or John?

From these list of questions, you can identify the attributes that must belong to entities within your data model.

Graph data model with properties