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.

How to create relation between nodes with same label in ETL tool from MySQL?

Hi, I'm tring to import info from MySQL database to Neo4j using ETL Tool,  and I already know that relation is built based on the foreign key according to https://neo4j.com/developer/neo4j-etl/.

But now my problem is that I don't know how to creat relation between nodes with same label, like this [: REPORTS_TO] relation in Employee node example:

chrome_9bXcUdor5D.png

 

 

3 REPLIES 3

If you want to create a relationships between employee with id = 0 (subordinate) and employee with id = 2 (superior), then the following query will do so:

match(n:Employee{id:0})
match(m:Employee{id:1})
merge(n)-[:REPORTS_TO]->(m)

If you want employee with id = 0 to report to himself, then the following will do so:

match(n:Employee{id:0})
merge(n)-[:REPORTS_TO]->(n)

 Is this what you are looking for?

Thanks for the reply. But I want this relation appear automaticly during the mapping stage when using ETL Tool, more specifically, I want to figure out if it's possible(if it is, then how) to config my foreign key of table from MySQL database, so that I dont have to set this relation myself back in Neo4j, like this below⬇

pic1.png

 

ameyasoft
Graph Maven

Under 'Actions' column add a flag named 'Self'  and use that flag in your code for self merging.