Course-GraphAcademy Graph Data Modeling Fundamentals-add a genre nodes

Anybody who can help me check the answer for the section in the course of neo4j Graph Academy:
Below is my answer:
MATCH (m:Movie)
UNWIND m.genres AS genre
WITH genre, collect(m) AS movies
MERGE (g:genre {name:genre})
WITH g, movies
UNWIND movies AS m
WITH g,m
MERGE (m)-[:IN_GENRE]->(g);
MATCH (m:Movie)
SET m.genres=null

I have checked the result that genre node has already been created, as the pic show

but when I click the "Check Database" button, I receive the " Oops! It looks like you haven't passed the test......." message

Anybody who can help me, thank you soooo much!!!

Can you provide a link to the question?

1 Like

Below is the link, thank you :heart:

https://graphacademy.neo4j.com/courses/modeling-fundamentals/6-eliminating-duplicate-data/5-c-refactor-genre-data/

1 Like

Here you go:

//refactor code
MATCH (m:Movie)
UNWIND m.genres AS genre
MERGE (g:Genre {name: genre})
MERGE (m)-[:IN_GENRE]->(g)
SET m.genres = null;

//revised query
MATCH (p:Actor)-[:ACTED_IN]-(m:Movie)--(g:Genre)
WHERE p.name = 'Tom Hanks' AND
g.name = 'Drama'
RETURN m.title AS Movie

1 Like

Thank you for answering, it works :heart: