Suggestions for 4.0-intro-neo4j-exercises/03.html

http://guides.neo4j.com/4.0-intro-neo4j-exercises/03.html

First:

Labels in Relationships are different from Labels in Nodes (in particular a Node can have 0,1, or more Labels).

One exercise shows:

MATCH (m:Movie)-[rel]-(:Person {name: 'Tom Hanks'}) RETURN m.title, type(rel)

where type(rel) is how you get the one Label for a relationship.

One might naively expect to use type() for Nodes, but that is wrong. You need the function labels(). (It's a bit bit confusing since Label refers to both Nodes and Relationships.). So this is how you would get all the Labels for a Movie Node. Since in the Movies DB, movies only have one sort of Label this would return a list of just one Label:

MATCH (m:Movie)-[rel]-(:Person {name: 'Tom Hanks'}) RETURN m.title, labels(m)

Second:

For the query:
MATCH (m:Movie)-[rel:ACTED_IN]-(:Person {name: 'Tom Hanks'}) RETURN m.title, rel.roles

it would be good to point out there are some movies where Tom Hanks placed multiple roles. Hence the roles property is actually a Neo4J List.

One interesting query is to order the movies where Hanks had the most roles:

MATCH (m:Movie)<-[rel:ACTED_IN]-(:Person {name: 'Tom Hanks'})
RETURN size(rel.roles) AS Size, m.title, rel.roles ORDER BY Size DESC

Thank you @clem.izurieta

I have incorporated your interesting query into the Exercise 8.5 of the browser guide.

Elaine