영어원문: https://neo4j.com/docs/cypher-manual/current/clauses/merge/
이번엔 relationship(edge), 엣지를 그을 때의 MERGE 사용법을 다룬다. node(노드) 만들 때의 사용법은 바로 이전 글에.
CREATE CONSTRAINT ON (n:Person) ASSERT n.name IS UNIQUE;
CREATE CONSTRAINT ON (n:Person) ASSERT n.role IS UNIQUE;
이런식으로 노드의 property가 unique하도록 지정할 수 있다
+ 다만 2020년 기준(neo4j 2.0.1) 여러 프로퍼티에 uniqueness 제약을 걸 수 없다고 한다. Enterprise edition neo4j 3.3에서는 node key constraints를 사용해 여러 프로퍼티에 유니크 constraint를 걸수 있다.
참고: https://neo4j.com/docs/cypher-manual/current/constraints/#administration-constraints-node-key
Constraints - Neo4j Cypher Manual
This section explains how to manage constraints used for ensuring data integrity.
neo4j.com
MERGE (n:User{name: "hail", height:"155"})<-[r:OWNER_OF]-(n1:Pet{name:"bbobbi"})
이렇게 유일한 property를 잘 서술해서 relationship edge를 만들 수도 있다.
'Database > GDB' 카테고리의 다른 글
Neo4j로 그래프db(GDB) 다루기: relationship(Edge) 삭제하는데 갑자기 노드를 새로 생성한 경우, relationship 생성하는데 노드가 하나 더 생성된 경우 (0) | 2021.08.12 |
---|---|
Neo4j로 그래프db(gdb) 다루기: SET (0) | 2021.08.12 |
Neo4j로 그래프db(gdb) 다루기: MERGE 1 (0) | 2021.08.11 |