Model

The Model tool is used to create Neo4j data models. Neo4j is schema agnostic, yet as you add data into Neo4j an implicit model is formed that consists of Node Labels, Relationship Types, and their Properties. The Model tool helps formulate a Neo4j data model prior to ingestion, to assist in conceptualizing and visualizing the problem domain as represented by a graph.

A Note on Data Modeling

A Neo4j graph database is a labeled property graph. The graph consists of nodes and relationships. Each node can have one or more Node Labels, and the name of the relationship is the Relationship Type. Both nodes and relationships can have properties, which are key/value pairs.

A node that has a particular Node Label is an instance of that Node Label. A relationship that has a particular Relationship Type is an instance of that Relationship Type. The data model itself is typically concerned with Node Labels and Relationship Types, which specify the general structure of the graph.

For example, consider the statement Alice works for Neo4j. To model this we will say that 'Alice' has a Node Label 'Person' and a property 'name', 'Neo4j' has a Node Label 'Company' and a property 'name', and there is a relationship WORKS_FOR that relates node Alice with node Neo4j. In Cypher this would look like:

(alice:Person {name: 'Alice'})-[:WORKS_FOR]→(neo4j:Company {name:'Neo4j'})

Our data model then would be (:Person {name})-[:WORKS_FOR]→(:Company {name}).

The data model itself provides the structure for how to both load and query data within Neo4j.

Instance Modeling

Sometimes it is useful to work specifically with Instances. This is especially useful during conceptualizing the problem. In the Model tool, if you re-use the name of a Node Label (e.g. use Person twice) within the model canvas, a tag will appear indicating it’s an Instance model.

As an example, we might want to model (:Person)-[:KNOWS]→(:Person), or more specifically (:Person {name:'Alice'})-[:KNOWS]→(:Person {name:'Bob'}). We now have 2 instances of Person, 'Alice' and 'Bob' and they are related by the :KNOWS relationship.

Be aware that Instance Models may not be directly appropriate for loading data into Neo4j. This is because the data model acts as a "template" to load data you have in CSV files or source databases. When you use an instance model, you are populating the model with representative data which may need to be removed prior to loading data.

More Information

This documentation primarily focuses on how to use the Model tool features to build a graph data model. It does not go over the techniques, approaches, and best practices of graph data modeling. For information on how to approach graph data modeling, please check out the courses in the Graph Academy.

Menus

The functionality of the Model tool can be accessed via the menus and the canvas:

Click on an item above to get more information.