Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Neo4j Graph Data Modelling

You're reading from   Neo4j Graph Data Modelling Design efficient and flexible databases by optimizing the power of Neo4j

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781784393441
Length 138 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Mahesh K Lal Mahesh K Lal
Author Profile Icon Mahesh K Lal
Mahesh K Lal
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Graphs Are Everywhere FREE CHAPTER 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

Querying the data model to find what is accessible to an employee


To find which hotels are accessible to an employee, we can traverse the :CAN_ACCESS relationships. The following query gets all the hotels accessible to an employee via all the groups the employee has access to, and also returns all the airports and locations of the hotels to which the employee has access:

MATCH p = (chain:HotelChain)<-[:EMPLOYED_BY]-(employee:Employee{_id:17812})-[:MEMBER_OF]->(:AccessGroup)-[:CAN_ACCESS*0..]->(hotel:Hotel)-[:BELONGS_TO]->(hotelChain:HotelChain)
WITH p, hotel
MATCH (hotel)<-[:HAS_HOTEL]-(airport:Airport)<-[:HAS_AIRPORT]-(city:City)
RETURN p, hotel, airport, city

The output of the preceding query is as follows:

Figure 7.15: Hotels accessible to members of the European Union access group of Accor hotels

For an employee of a subsidiary of Accor hotels, the accessible hotels will be a smaller subset. The following query tries finding all hotels accessible to a different employee...

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 $19.99/month. Cancel anytime