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

Adding hotels to airports


Now that we have airports as nodes, we can add hotels to our data model. As discussed earlier, hotels have an ID, name, and average price.

Let's start by adding a constraint on the ID of the hotel, which is the _id property, as shown:

neo4j-sh (?)$ CREATE CONSTRAINT ON (hotel:Hotel) ASSERT hotel._id IS UNIQUE;

The output of the preceding query is as shown:

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

We can add a hotel and connect it to the JFK airport using the following query:

neo4j-sh (?)$ CREATE (hotel:Hotel {_id:"6ad8ce6e-1c0e-11e5-8db1-6c40089a9424",  name:"Hilton", price: 180})
WITH hotel
MATCH (airport:Airport{code:"JFK"})
WITH airport, hotel
MERGE (airport)-[:HAS_HOTEL]->(hotel)
RETURN airport, hotel;

The output of the preceding query is as follows:

Figure 5.8: Airport hotels

Note

We can add more hotels from the hotels.cqy file that can be downloaded along with the code for this chapter.

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