cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Creating relationships when you have just one of the nodes constrained and the other not?

Hello every one. I would like to know how can I create relationships when one of the nodes has constraints while the other one has no constraints. While I load the csv file and try to make the relationship between these two nodes I am having troubles and unnecessary relationships are created?

1 ACCEPTED SOLUTION

MERGE (a:Node {primary_key: guid})
CREATE (a)-[r1:relationship]->(b:Node {attributes: stuff})
CREATE (a)-[r2:relationship]->(c:Node {attributes: stuff})
CREATE (a)-[r3:relationship]->(d:Node {attributes: stuff})
RETURN *

View solution in original post

3 REPLIES 3

I assume you mean the node with a constraint, you're just trying to avoid duplicates of the node being created, and the other nodes you want multiples of? Use MERGE for the node you want to keep unique and CREATE for the other nodes that you should have duplicates of.

Thanks for replying. I have one node which is constrained by an attribute name and 5 other nodes that will be connected to this node but they cannot be constrained by any attribute. How can I create the relationship between the first node and other nodes but to not have a cartesian connection? Also can we assign uuid for the nodes to we can use the uuid to make the matching between nodes?? Thanks

MERGE (a:Node {primary_key: guid})
CREATE (a)-[r1:relationship]->(b:Node {attributes: stuff})
CREATE (a)-[r2:relationship]->(c:Node {attributes: stuff})
CREATE (a)-[r3:relationship]->(d:Node {attributes: stuff})
RETURN *