Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Neo4j Graph Data Modelling
  • Toc
  • feedback
Neo4j Graph Data Modelling

Neo4j Graph Data Modelling

By : Mahesh K Lal
3 (1)
close
Neo4j Graph Data Modelling

Neo4j Graph Data Modelling

3 (1)
By: Mahesh K Lal

Overview of this book

If you are a developer who wants to understand the fundamentals of modeling data in Neo4j and how it can be used to model full-fledged applications, then this book is for you. Some understanding of domain modeling may be advantageous but is not essential.
Table of Contents (11 chapters)
close
10
Index

Creating cities in Neo4j

We will model cities as nodes, as shown in Figure 2.4, with the city's name and country as properties. Cities should have unique names. For this, we can add a constraint before we start creating cities in our graph.

The query is as follows:

neo4j-sh (?)$ CREATE CONSTRAINT ON (city: City) ASSERT city.name IS UNIQUE;

The output of the preceding query is as shown:

+-------------------+
| No data returned. |
+-------------------+
Constraints added: 1

This adds a constraint on all nodes that will henceforth be created with the label City to have a unique name property. The city in (city: City) is a placeholder, like a variable, for any node with label City. Note that the addition of a uniqueness constraint is idempotent—it can be repeated multiple times without throwing an error or changing the constraint after it first gets added.

It's a good practice to add a uniqueness constraint, like we did, before we start adding nodes that have a particular label. While...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete