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:
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...