Purpose of the Model

Types of models

When performing the graph data modeling process for an application, you will need at least two types of models:

  • Data model

  • Instance model

Data model

The data model describes the labels, relationships, and properties for the graph. It does not have specific data that will be created in the graph.

Here is an example of a data model:

Data model

There is nothing that uniquely identifies a node with a given label. A graph data model, however is important because it defines the names that will be used for labels, relationship types, and properties when the graph is created and used by the application.

Style guidelines for modeling

As you begin the graph data modeling process, it is important that you agree upon how labels, relationship types, and property keys are named. Labels, relationship types, and property keys are case-sensitive, unlike Cypher keywords which are case-insensitive.

A Neo4j best practice is to use the following when you name the elements of the graph, but you are free to use any convention for your application.

  • A label is a single identifier that begins with a capital letter and can be CamelCase.

    • Examples: Person, Company, GitHubRepo

  • A relationship type is a single identifier that is in all capital letters with the underscore character.

    • Examples: FOLLOWS, MARRIED_TO

  • A property key for a node or a relationship is a single identifier that begins with a lower-case letter and can be camelCase.

    • Examples: deptId, firstName

Note: Property key names need not be unique. For example, a Person node and a Movie node, each can have the property key of tmdbId.

Instance model

An important part of the graph data modeling process is to test the model against the use cases. To do this, you need to have a set of sample data that you can use to see if the use cases can be answered with the model.

Here is an example of an instance model:

Instance model

In this instance model, we have created some instances of Person and Movie nodes, as well as their relationships. Having this type of instance model will help us to test our use cases.

Check your understanding

1. Purpose of models

Why do we create an instance model during our modeling process?

  • ❏ To help with loading data into the graph.

  • ✓ To help us confirm that our data model can satisfy use cases of the application.

  • ❏ It is required for data import.

  • ❏ It is used to generate the graph when the database starts.

Hint

You must do this to help you confirm that your use cases can be answered by the model.

Solution

You may choose to create an instance model to help us confirm that our data model can satisfy use cases of the application.

Summary

In this lesson, you learned the difference between a graph data model and an instance model and why each are important as you develop the graph that will be used for the application. In the next module, you will learn about modeling entities in your domain as nodes.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?