In this challenge, you will apply what you have learned to find a node, create a new node, and create a relationship between them.
Create an ACTED_IN Relationship between Daniel Kaluuya and the movie Get Out
Replace the ????? in the Cypher statement to:
-
Find the Person node for Daniel Kaluuya.
-
Create a Movie node, with a
title
property of Get Out. -
Add an ACTED_IN relationship between Daniel Kaluuya and the movie, Get Out.
MATCH (p:Person {name: 'Daniel Kaluuya'})
MERGE (m:Movie {title: '?????'})
MERGE (?)-[:?????]->(?)
You can confirm that the relationship was created using the following query:
MATCH (p:Person {name: 'Daniel Kaluuya'})
MATCH (m:Movie {title: 'Get Out'})
MATCH (p)-[:ACTED_IN]->(m)
RETURN p, m
Validate Results
Once you have run the query, click the Check Database button and we will check the database for you.
Hint
After creating the nodes, you create the :ACTED_IN
relationship using MERGE between the p
and m
nodes.
The labels, properties, relationship type, and values are all case sensitive.
Solution
You can run the following query in the Sandbox query to create the relationship between Daniel Kaluuya and Get Out:
MATCH (p:Person {name: 'Daniel Kaluuya'})
MERGE (m:Movie {title: 'Get Out'})
MERGE (p)-[:ACTED_IN]->(m)
Summary
In this challenge, you demonstrated that you can find a node, create a new node, and create a relationship between them. In the next lesson, you will learn how to add, update, and remove properties from nodes and relationships.