Adding the Director Label

In a previous Challenge, you added the Actor label to the nodes in the graph.

Modify the query in the sandbox query pane to label the Person nodes that have the outgoing relationship of DIRECTED to be labeled Director.

The new label will be Director. Your code should add 2 labels to the graph.

After refactoring the graph, you must test any use cases that are affected.

Use case #2: What person directed a movie?

Copy this query into the query pane, and modify it to use the Director label, then test this use case using the movie, Hoffa.

cypher
MATCH (p:Person)-[:DIRECTED]-(m:Movie)
WHERE m.title = 'Hoffa'
RETURN  p.name AS Director

It should return Danny DeVito.

Validate Results

Once you have run the query, click the Check Database button and we will check the database for you.

Hint

All nodes that have the DIRECTED outgoing relationship will need to have an additional Director label.

Solution

Here is the query required to add the Director label to all Person nodes connected to a Movie by at least one DIRECTED relationship.

cypher
MATCH (p:Person)
WHERE exists ((p)-[:DIRECTED]-())
SET p:Director

Click Run in Sandbox to apply the label before clicking Try again…​.

Summary

In this challenge, you demonstrated that you can refactor the graph to add a DIRECTOR label to some of its nodes and retest relevant use cases.

Your instance model should now look like this:

Instance Model thus far

In the next lesson, you will learn some tips about what not to do with labels in your graph data model.