cancel
Showing results for 
Search instead for 
Did you mean: 

Graph Data Modeling Fundamentals Adding a role node

asyiqinmn
Node

helpp, im stuck at this question. can anybody help? it is the learning module in neo4j

Write and run refactor code to:

  1. Find an actor that acted in a Movie ( MATCH (a:Actor)-[r:ACTED_IN]-(m:Movie) )
  2. Create (using MERGE ) a Role node setting it’s name to the role in the ACTED_IN relationship.
  3. Create (using MERGE ) the PLAYED relationship between the Actor and the Role nodes.
  4. Create (using MERGE ) the IN_MOVIE relationship between the Role and the Movie nodes.
  5. Remove the role property from the ACTED_IN relationship (set it to null)
5 REPLIES 5

prabhitha3
Node

MATCH (a:Actor)-[r:ACTED_IN]-(m:Movie) MERGE (x:Role {name: r.role}) MERGE (a)-[:PLAYED]→(x) MERGE (x)-[:IN_MOVIE]→(m) SET r.role = null
This is given as the solution code but it's not working. I Updated it as below, still not working. Can somebody help?
MATCH (a:Actor)-[r:ACTED_IN]-(m:Movie) WHERE r.role is NOT NULL MERGE (x:Role {name: r.role}) MERGE (a)-[:PLAYED]-(x) MERGE (x)-[:IN_MOVIE]-(m) SET r.role = null

Hello @prabhitha3 and welcome to the Neo4j Community!

What error are you getting when you run the solution code?

It is possible that your graph has been refactored to a state that is not expected in the challenge.
I recommend that you do the following:

  1. Go to the sandbox.neo4j.com site and terminate your blank sandbox used for this course.
  2. Re-enter the challenge which will re-create the sandbox and reset the database to what it should be before you start the challenge.
  3. Attempt the challenge again.

Elaine

abhayweb
Node

Hi,

I'm facing the same issue. I tried to terminate the sandbox and restart the challenge. However, I still face the same issue. It says "You havent passed the Test". When I check the graph data, I see all the expected Nodes and relationships correctly built. Is there a way to see what the error is? 

If you terminate your sandbox and refresh the page for this challenge, it should put the graph in the state it should be for the beginning of this challenge.   It will take a least a minute for the sandbox to be created. It is usable after the $neo4j prompt appears.

Note: Make sure you are not using this blank sandbox for any other purpose than this course.

If you execute the Cypher code shown as the solution to this challenge, the database should verify. 
Can you try again?

Elaine

 SET r.role = null  NOT needed

Run in Sandbox
// Find an actor that acted in a Movie
MATCH (a:Actor)-[r:ACTED_IN]->(m:Movie)

// Create a Role node
MERGE (x:Role {name: r.role})

// Create the PLAYED relationship
// relationship between the Actor and the Role nodes.
MERGE (a)-[:PLAYED]->(x)

// Create the IN_MOVIE relationship between
// the Role and the Movie nodes.
MERGE (x)-[:IN_MOVIE]->(m)


This query should add 5 labels, create 5 nodes, set 5 properties, and create 10 relationships.

Click Run in Sandbox to execute the query and then click the Try again…​ button to verify that the query has succeeded.

If the numbers do not match up, try refreshing your browser to reset the data in your Sandbox instance.