The exercise is: "Retrieve all directors, their movies, and people who acted in the movies, returning the name of the director, the number of actors the director has worked with, and the list of actors." However, the posted answer doesn't include the movies.
Posted answer:
"MATCH (d:Person)-[:DIRECTED]->(m:Movie)<-[:ACTED_IN]-(a:Person) RETURN d.name AS director, count(a) AS number actors
, collect(a.name) AS actors worked with
"
I believe the correct (or more complete) answer is:
MATCH (d:Person)-[:DIRECTED]->(m:Movie)<-[:ACTED_IN]-(a:Person)
RETURN d.name AS director, collect(DISTINCT m.title) AS movies directed
, count(a) AS number actors
, collect(a.name) AS actors worked with
(I'm still trying to understand why I need to include DISTINCT to prevent duplicate movie titles. An earlier post about exercise 6.3 seems close but I'm not sure it directly relates to this query.)