Book Image

Neo4j Graph Data Modelling

Book Image

Neo4j Graph Data Modelling

Overview of this book

Table of Contents (16 chapters)
Neo4j Graph Data Modeling
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating bookings and users in Neo4j


For bookings to exist, we should create users in our data model.

Note

As with earlier chapters, please download the queries from the downloadable code bundle available with this book. Alternatively, the queries can also be downloaded from https://github.com/maheshlal2910/neo4j_graph_data_modelling.

Creating users

To create users, we create a constraint on the e-mail of the user, which we will use as an unique identifier as shown in the following query:

neo4j-sh (?)$ CREATE CONSTRAINT ON (user:User) ASSERT user.email IS UNIQUE;

The output of the preceding query is as follows:

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

With the constraint added, let's create a few users in our system:

neo4j-sh (?)$ CREATE (:User{name:"Mahesh Lal", email:"[email protected]"}),
  (:User{name:"John Doe", email:"[email protected]"}),
  (:User{name:"Vishal P", email:"[email protected]"}),
  (:User{name:"Dave Coeburg", email:"dave.coeburg...