I'm trying to form a relationship b/w parent and child.
MERGE (c:Child{name:'CA'})
MERGE (p:Parent{name:'Parent'})
For creating a relationship,
MERGE (p)-[:parent_of]->(c)
This queries are written in a separate java function named createParentChildRelationship.
Whenever I try to call this function with a same Parent name with a different child name passing a parameter to the function, it forms a new relationship . But I need only the current child node to point the parent node, by deleting the previous child nodes and it's relationship with the parent.
So I tried this way of approaching it,
MERGE (c:Child{name:'CA'})
MERGE (p:Parent{name:'Parent'})
MATCH (c)-[r:parent_of]-(p) DELETE r, c, p
CREATE (p)-[:parent_of]->(c)
But it shows me 1 property is set but relationship isn't created