Creating a Relationship

We want to make another addition to the graph.

Use the sandbox window to the right to add a new node and relationship to the graph:

  1. Find the Person node for Daniel Kaluuya.

  2. Create the Movie node, Get Out.

  3. Add the ACTED_IN relationship between Daniel Kaluuya and the movie, Get Out.

You will do a MATCH to find the person. Then you will do a MERGE to create the movie node. Remember that our other Movie nodes contain a property called title. Then you will do a MERGE to create the relationship.

Validate Results

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

Hint

To find the match the pattern in the database, we would run the following Cypher statement:

cypher
MATCH (p:Person) WHERE p.name = 'Daniel Kaluuya'
MATCH (m:Movie {title: 'Get Out'})
MATCH (p)-[:ACTED_IN]->(m)
RETURN p, m

Hint: All you need to do is change the first keyword in the second and third lines to create the movie and relationship.

Solution

You can run the following query in the Sandbox query to create the relationship between Daniel Kaluuya and Get Out:

cypher
MERGE (p:Person {name: 'Daniel Kaluuya'})
MERGE (m:Movie {title: 'Get Out'})
MERGE (p)-[:ACTED_IN]->(m)
RETURN p, 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.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?