Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
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
1. Graphs Are Everywhere 2. Modeling Flights and Cities 3. Formulating an Itinerary 4. Modeling Bookings and Users 5. Refactoring the Data Model 6. Modeling Communication Chains 7. Modeling Access Control 8. Recommendations and Analysis of Historical Data 9. Wrapping Up Index

Adding flights to Neo4j


Since we have identified flights as entities, we will create them as nodes. To begin with, we should create a uniqueness constraint on the property code for the label :Flight as shown:

neo4j-sh (?)$ CREATE CONSTRAINT ON (flight:Flight) ASSERT flight.code IS UNIQUE;

The output is as follows:

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

We can create a flight with its information as a standalone entity:

neo4j-sh (?)$ CREATE (flight:Flight {code:"AA9", carrier:"American Airlines", duration:314, source_airport_code:"JFK", departure:1300, destination_airport_code:"LAX", arrival:114}) RETURN flight.code as flight_code, flight.carrier as carrier, flight.source_airport_code as from, flight.destination_airport_code as to;

The output is as follows:

+---------------------------------------------------+
| flight_code | carrier             | from  | to    |
+---------------------------------------------------+
| "AA9"       | "American Airlines...
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}