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.

Create Dynamic relationship between two nodes based on another node?

Hi guys

I am new to this community as well as neo4j

So actually the below is the question.

Node A(Member) Node B(Member)

Node C(Member sponsor)

Now I need to make relation between A and B using the properties of C.

It has to be work continuosly like a Trigger in MySQL.

The relation details will be on Node C only.

And it will work when ever data comes into the neo4j forever.

Is this possible.

3 REPLIES 3

If you can enable them on the server, you should be able to configure this with apoc triggers

Assume I am having member nodes with property like this already

{name:"a",empId:"123"}
{name:"b",empId:"222"}
{name:"c",empId:"333"}
{name:"d",empId:"444"}

Now the another new node came in with a new label as sponsor
{Name:"test",sourceEmpId:"123",destEmpId:"333"}
Name:"test",sourceEmpId:"222",destEmpId:"444"}

So generally the node with label sponsor came later.

As soon as that sponsor node start to arrives we need to create relation between the member nodes based on the sponsor properties of source and destination emp id.

Can anyone help on this situation??

Any help appreciated

Would it make sense to modify the sponor insert transaction in such a way that it creates the relation?

match(s:Member) where s.empID="123" with s
match (d:Member) where d.empID="333" with s,d
merge(sp:MemberSponsor {Name:"test", sourceEmpId="123",destEMPId="333"}) with s,d,sp
merge (s)-[r:MyRelation]->(d)

i depending on other requirements I would model the sponsorship real like

match(s:Member) where s.empID="123" with s
match (d:Member) where d.empID="333" with s,d
merge(sp:MemberSponsor {Name:"test"}) with s,d,sp
merge (s)-[p:MyRelation]->(sp)-[s:MyRelation]->(d)

This could probably better leverage the benefit of graph libraries.