Now that the schema has been updated we can add data as triples.
Dgraph creates its own internal id’s for nodes, but we need some way to refer to
the same node many times in our input data. That’s what _:company1
does.
Technically, these are ‘blank nodes’. They tell Dgraph to create a node, give it an internal id and make sure it’s used consistently.
After the upload, the label _:company1
doesn’t exist in Dgraph and we can’t
query for it. You’ll see in the result that Dgraph has replaced it with an
internal id. You can query for this internal id — remember
func: uid(<uid_number>)
.
Making changes to the graph stored in Dgraph is called mutating the data.
You can load the same example data using JSON format. You’re able to do that through our clients, cURL or Ratel UI.
See the JSON:
The JSON example may end up helping you better understand the format in RDF.
{
set {
_:company1 <name> "CompanyABC" .
_:company1 <dgraph.type> "Company" .
_:company2 <name> "The other company" .
_:company2 <dgraph.type> "Company" .
_:company1 <industry> "Machinery" .
_:company2 <industry> "High Tech" .
_:jack <works_for> _:company1 .
_:jack <dgraph.type> "Person" .
_:ivy <works_for> _:company1 .
_:ivy <dgraph.type> "Person" .
_:zoe <works_for> _:company1 .
_:zoe <dgraph.type> "Person" .
_:jack <name> "Jack" .
_:ivy <name> "Ivy" .
_:zoe <name> "Zoe" .
_:jose <name> "Jose" .
_:alexei <name> "Alexei" .
_:jose <works_for> _:company2 .
_:jose <dgraph.type> "Person" .
_:alexei <works_for> _:company2 .
3.2 Adding Data - mutating data