Dgraph DQL Tour

Schema

Exercise : Integrating existing data

We’ve added a new schema and loaded some company data, but what about integrating our previous friends dataset with this company one.

Trying to use the blank nodes from previous mutations won’t work. The blank nodes aren’t persisted in the store, so when referring to nodes created in a previous mutation, it’s the UID that’s needed. So instead of

_:sarah <works_for> _:company1 .

it’s

<uid_of_sarah> <works_for> <uid_of_company1> .

Because the uid picked by Dgraph is unique, we can’t help you this time. Use the uid’s picked by your instance of Dgraph to write a mutation that links the company and friendship data (hint: previous queries will tell you the uid).

The process you’ve just done here would normally done programmatically - query the data to get the uid’s, formulate the mutations, then batch the updates.

Don’t worry if you can’t find the uids, you can always search by name:

3.7 Exercise : Integrating existing data