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

Traversing relationships


Traversing relationships in Neo4j is done by specifying the path that we want to be matched. Queries can be open ended, like the one here, in which we haven't highlighted the direction in which we want the relationship to be traversed. Other open-ended queries might refrain from specifying the relationship type to be traversed or the node labels that would identify the subgraph that needs to be traversed.

Input the following query:

neo4j-sh (?)$ MATCH (source:City {name:"Los Angeles"})->[:HAS_FLIGHT]-(f:Flight)-[:FLYING_TO]->(destination:City {name:"New York"}) RETURN f.code as flight_code, f.carrier as carrier;

The output of this query is as follows:

+-----------------------------------+
| flight_code | carrier             |
+-----------------------------------+
| "UA1262"    | "United"            |
| "AA920"     | "American Airlines" |
+-----------------------------------+
2 rows
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}