Reduce the number of relations in the appearance

image
ex : I want to make only one relation "POSTED" outgoing from "NOREVIE" knowing that it ends up by having 4 relations after .

Can you give a little more context ?

For example how do you create your data in Neo4j ?
I assume it's via GraphQl, but what is your schema, what is your resolver for creating those relationship, ...

In Cypher to avoid this, you can use the Merge :

MATCH (start: ....)
MATCH (end: ....)
MERGE (start)-[:POSTED]->(end)
1 Like

Well I just imported 5 csv files : DO , Contrat , Attrib , DOCO(in which I have DO/Contrat Rleationship )and COAT (in which I have Contrat/Attrib relationship) and I used those two queries for relationships :
Query 1 : DOCO :
LOAD CSV WITH HEADERS FROM 'file:///DOCO.csv' AS DonneursDordre
MATCH(do:DO {id: DonneursDordre.DO_ID}), (c:Contrat {id: Contrats.Contrat_ID})
CREATE (do)-[:POSTED]->(c)

Query 2 : COAT :
LOAD CSV WITH HEADERS FROM 'file:///COAT.csv' AS Contrats
MATCH (c:Contrat {id: Contrats.Contrat_ID}) , (at:Attrib {id: Contrats.Attrib_ID})
CREATE (c)-[:ASSIGNED]->(at)

Like I said in my first answer, you need to use the pattern MATCH, MATCH, MERGE during your import.

So you should use this script instead :

LOAD CSV WITH HEADERS FROM 'file:///DOCO.csv' AS DonneursDordre
MATCH (do:DO {id: DonneursDordre.DO_ID}), 
      (c:Contrat {id: Contrats.Contrat_ID})
MERGE (do)-[:POSTED]->(c)

With this script, you will have only one relationship between a DO and a Contract, even if there are many lines in your csv.

Cheers

1 Like

Can I just update it without reloading ?
Thanks a lot !

Nop, you need to delete your database and to reload your scripts

1 Like

Perfect ! Thanks a lot :)