I heard about dgraph from the Changelog podcast a couple years ago and it came to mind now that we’re looking at DBs. We’d like to create a read replica off of our legacy database which you could think of as a document database. I’ve read through the Mutations article and the JSON importer looks useful. I think I need the “External IDs” but the examples aren’t making a lot of sense to me.
I’m struggling to understand how we model and update a row of data, especially since we dont know the internal (dgraph) ID of each row. We’re going to start POC’s next week comparing Mongo, Postgres, and dgraph and any help you could provide to figure out how to do both the initial load and “streaming updates” would be helpful.
Here’s a super simple example to start with. The first data set has two tables with a primary key and then theres a join between the two tables. The second data set has updates and an insert. I think my main question is:
How can I format the JSON so that when the second data set is added, Account 1 and 2 get updated, and Account 3 gets added?
Initial data set
Account CSV file #1 (Initial insert)
ID,Balance,Transactions
1,100,[1,3]
2,250,[2,4]
Transactions CSV file #1 (Initial insert)
ID,AccountId,Amount
1,1,75
2,2,150
3,1,75
4,2,150
Second Dataset
Account CSV file #2 (Update)
ID,Balance,Transactions
1,100,[1,3,5]
2,250,[2,4,6]
3,50,[7]
Transactions CSV file #2 (Update)
ID,AccountId,Amount
5,1,-50
6,2,-50
7,3,50