In the Graph Academy we have Exercise 4, Part 5 with this question: 2. Retrieve the movies and their actors where one of the actors also directed the movie, returning the actors names, the director’s name, and the movie title.
I tried this:
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)<-[:DIRECTED]-(d:Person)
WHERE exists((d)-[:ACTED_IN]->(m))
RETURN p.name, d.name, m.title
the result seemed okay, with the exception of duplicated information. My Result
After my result, I saw the expected query from graph academy and it has some small changes, changing the DIRECTED to ACTED:IN and changing the exists with DIRECTED, like this:
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(d:Person)
WHERE exists((d)-[:DIRECTED]->(m))
RETURN p.name, d.name, m.title
whit this result: Correct result
We can see that there aren't any duplicated information like actor "Tom Hanks", director "Tom Hanks".
My question is, Why does Neo4j behaves like this with such a small change?