Here is the refactored instance model we will create in the graph where we add an Actor label to some of the Person nodes:

Refactor the graph
With Cypher, you can easily transform the graph to add Actor labels.
There are 5 Person nodes in the graph, but only 4 have an :ACTED_IN
relationship.
Update and execute the following Cypher code to:
-
Find all Person nodes that have an
:ACTED_IN
relationship. -
Set the Actor label to the appropriate nodes.
MATCH (p:Person)
WHERE exists ((p)-[:??????]->())
SET p:??????
Check the results
Once you have added the Actor
labels and refactored the graph, you can check the results by running the following query:
MATCH (p:Actor)
RETURN p
You should see 4 nodes with the Actor label.
Validate Results
Once you have run the code to add the Actor labels, click the Check Database button and we will check the database for you.
Hint
You will need to check the existence of Person
nodes with an ACTED_IN
relationship.
You can then set the Actor
label to the appropriate nodes.
Solution
Run this Cypher query to add the Actor label to the appropriate Person nodes.
MATCH (p:Person)
WHERE exists ((p)-[:ACTED_IN]->())
SET p:Actor
Summary
In this challenge, you demonstrated that you can refactor the graph to add additional labels to nodes.
In the next lesson, you will learn that you must retest your use cases after you refactor.