Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Neo4j Graph Data Modelling

You're reading from  Neo4j Graph Data Modelling

Product type Book
Published in Jul 2015
Publisher
ISBN-13 9781784393441
Pages 138 pages
Edition 1st Edition
Languages
Concepts

Table of Contents (16) Chapters

Neo4j Graph Data Modeling
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Graphs Are Everywhere Modeling Flights and Cities Formulating an Itinerary Modeling Bookings and Users Refactoring the Data Model Modeling Communication Chains Modeling Access Control Recommendations and Analysis of Historical Data Wrapping Up 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:"mahesh.lal@gmail.com"}),
  (:User{name:"John Doe", email:"john.doe@gmail.com"}),
  (:User{name:"Vishal P", email:"vishal.p@gmail.com"}),
  (:User{name:"Dave Coeburg", email:"dave.coeburg...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}