I am following the course Graph Data Modeling Fundamentals
On this sections Adding Language nodes they have this query to remove the langue property from nodes and create a new node and relationshiop to Movies
MATCH (m:Movie)
UNWIND m.languages AS language
WITH language, collect(m) AS movies
MERGE (l:Language {name:language})
WITH l, movies
UNWIND movies AS m
WITH l,m
MERGE (m)-[:IN_LANGUAGE]->(l);
MATCH (m:Movie)
SET m.languages = null
I don't understand why they have collect(m) AS movies and then UNWIND movies AS m.
I modified their query to this one and the result is the same:
MATCH (m:Movie)
UNWIND m.languages AS language
WITH language, m
MERGE (l:Language {name:language})
WITH l, m
MERGE (m)-[:IN_LANGUAGE]->(l);
MATCH (m:Movie)
SET m.languages = null
Is there any difference in execution?