Creating Relationship for Transaction Module

I would like to understand whether we would be able to achieve the following and guidance to achieve it:

For ex:-
Column headers :
from_accout,txn_date,txn_amount, txn_id,to_account
123,23-Aug-2020,100,txnid1,456
123,24-Aug-2020,120,txnid14,456
456,24-Aug-2020,500,txnid99,543
673,24-Aug-2020,200,txnid12,231

I will be creating relationship called "transfered_to" between "from_account" and "to_account" with txn_date , txn_amount and txn_id as relationship property

Whilst creating when there are transaction made to same account more than once I intended to create only one relationship where as it's relationship property values should get appended.

Considering the above example for first two rows , we should have create only one relationship where as it's relationship property should have the details of the both the transaction.

Hi,

At first we only created only all nodes.

LOAD CSV WITH HEADERS FROM 'file:///sampledata.csv' AS line
MERGE (:Account {id: line.from_account})
MERGE (:Account {id: line.to_account});

Then I created all relationships.

LOAD CSV WITH HEADERS FROM 'file:///sampledata.csv' AS line
MATCH (from:Account {id: line.from_account})
MATCH (to:Account {id: line.to_account})
MERGE (from)-[:TRANSFERED_TO {txn_date: line.txn_date, txn_amount: line.txn_amount, txn_id: line.txn_id}]->(to);

Cypher created two relationships between 123 and 456, which I think is fine.
I think it's not a good design to have multiple transaction properties in one relationship.
Does this answer your question?

1 Like
Here is my approach:

LOAD CSV WITH HEADERS FROM 'file:///sampledata.csv' AS line
MERGE (from:Account {id: line.from_account})
MERGE (to:Account {id: line.to_account});
MERGE (trndte:TranDate {dte: line.txn_date})

MERGE (trnamt:TranAmt {amount: txn_amount, txn_id: line.txn_id})

MERGE (from)-[:TO_ACCOUNT]->(to)-[:TRAN_DATE]->(trndte)-[:TRAN_AMOUNT]->(trnamt)

For the same from, to, and date the  (trndte) node will have multiple branches one for each amount.
In your case (trndate) will have two branches one for amount 100 and another for 120.

Having a separate node for transaction date will help you in your data analysis.
1 Like

Thanks a lot Koji. I will try to emulate in my test and see how it goes with our Business.

Thanks a lot Ameya. It gives whole lot of another perspective to displaying the date. I am going to simulate this as well and update here the progress.