0
votes

I am new to neo4j graph database. I was just playing with and tried different queries using cypher.

I have small question, Lets say I have Person and Movie Node. A Person acted and directed a same Movie. How can I create two relationships(say, ACTED_IN, DIRECTED) between same Person and movie node.

(Person)-[ACTED_IN]->(Movie) and (Person)-[DIRECTED]->(Movie)

Is it possible to do it or I am missing something to understand? Thank you

2

2 Answers

3
votes

I do not think that you should perform two queries, you can perform multiple updates in a single query like this:

MATCH (p:Person{name:'Clint Eastwood'}), (m:Movie{name:'Dirty Harry'}) CREATE p-[:ACTED_IN]->m, p-[:DIRECTED]->m

1
votes

You can do this:

MATCH (p:Person), (m:Movie) where p.name = 'Clint Eastwood' and m.name = 'Dirty Harry' CREATE (p)-[:ACTED_IN]->(m);

MATCH (p:Person), (m:Movie) where p.name = 'Clint Eastwood' and m.name = 'Dirty Harry' CREATE (p)-[:DIRECTED]->(m);