Foreign key realted file loading


(Shoukat Ghouse) #1

Hi,
We are exploring dgraph and i need to load multiple files with a parent child relationship.
Is there an way to achieve this? Any tips,tricks and references?


(Aman Mangal) #2

We have live loader [1] and bulk loader [2] that allow loading JSON and RDF data into a Dgraph Cluster.

[1] https://docs.dgraph.io/deploy/#live-loader
[2] https://docs.dgraph.io/deploy/#bulk-loader


(Shoukat Ghouse) #3

I know of the loaders buy my question is more specific on loading process… Can I load two different files with a linkage column and dgraph can auto create the nodes. Is this available out of the box?
For example I have 1 file custId,name and another file with custId, account… How can I load these two files separately in dgraph and get the relationships created without having to first load file 1 , get uuid for cust Id and then same the same uuid for file 2 for the same cust id…


(Aman Mangal) #4

You can pass both the files to either of the loaders in expected format, it will be taken care of. For example -

File 1

_:custId < name > “name” .
_:custId <customer_id> “customer_id” .

File 2

_:custId < account > “account” .

(remove the spaces around angular brackets)

If you can’t pass both the files to the loaders together and have to do it one file at a time, first you can’t use the bulk loader (it is faster than live loader, it is preferred to use). You will have to use the live loader. Then, you could use the option -x, --xidmap to store the mapping on disk while processing the first file. Then, reuse the same option with same path while processing the second file.