简体   繁体   中英

How to create two relationship between nodes in graph DB

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

我认为您不应该执行两个查询,而是可以在一个查询中执行多个更新,如下所示:

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM