I have three independent category trees that is going to import at any order using cypher.
- (c2)-[PARENT]->(c1)
- (c4)-[PARENT]->(c3)->[PARENT]->(c1)
- (c5)-[PARENT]->(c3)

and need to create the structure mentioned in the figure using the query . The query I written is
MERGE (:Category {name:'c2'})-[:PARENT]->(:Category {name:'c1'})
MERGE (:Category {name:'c4'})-[:PARENT]->(:Category {name:'c3'})-[:PARENT]->(:Category {name:'c1'})
MERGE (:Category {name:'c5'})-[:PARENT]->(:Category {name:'c3'})
But above query creating duplicate category c1 for second merge query which I need to avoid . Also the third query should create new category c3 which is happening correctly now.
One more thing is that these three cypher query should be independently executable .eg: System already have a category tree (c2)-[PARENT]->(c1) and need to add (c4)-[PARENT]->(c3)->[PARENT]->(c1) in to the category tree using cypher.
I can go with some similar approach mention in the documentation http://neo4j.com/docs/stable/cypherdoc-linked-lists.html . but just want to check is there a simple way to solve this problem