Graph databases: Practical Exercises

In Moodle, please submit three files: exercise2a.cypher, exercise2b.cypher, and exercise2c.cypher. If you haven't completed all parts, you can submit blank files. However, we recommend developing and debugging on your own machine before going to Moodle.

Exercise 2.a

Write a cypher query to return name, total where name is the name of an actor and total is the number of movies they act in.

   YOUR-CODE-GOES-HERE
   order by total desc, name
   limit 10;

Exercise 2.b

Write a cypher query that returns name, roles1, roles2 where name is the name of an actor, roles1 are the roles played in the movie The Matrix Reloaded, and roles2 are the roles played in the movie John Wick.

   YOUR-CODE-GOES-HERE
   order by name, roles1, roles2;

Exercise 2.c

In the graph tutorial we saw the cypher query for computing each bacon number associated with people in our database and the total with that bacon number:

match path=allshortestpaths(
          (m:Person {name : "Kevin Bacon"} ) -[:ACTED_IN*]- (n:Person))
     where n.person_id <> m.person_id
     return length(path)/2 as bacon_number,
            count(distinct n.person_id) as total
order by bacon_number;

Just as a given movie can be associated with many actors, a given movie can be associated with many producers. Modify the above query to compute the spielberg_number that starts with "Steven Spielberg" and counts the people using the coproducer relationship rather than a coactor relationship. Don't forget to rename rename bacon_number to spielberg_number!