Thank you for your reply.
It is strange to me after using relational databases. Looks like this storing data are natural way for dgraph. But what if I want to add nodes without relations, but add them later. How should I link them later in that case? I mean add in database two (for example) separate nodes and after some time join them. I want to avoid data replication. (Will adding relations between for example rule and device create copy of rule for device?)
Also one node can have many relations with other nodes. So every node should store copy of it? I mean if we create nodes with same nested node for example many devices with one rule, is every device will store copy of rule ? Or dgraph under the hood use pointer on that node instead it copy ?
I would highly suggest using the protobuf NQuads interface within the go library to use a typed system of inserting data, as opposed to the SetJson member of the requests. (its basically a protobuf representation of the RDF format, if you prefer string building, you can use that).
With the NQuads typed interface, you can just set the ObjectId to the uid(eg: 0x123) you wish to point to within a NQuad object.
You can also use upserts to look up ids as well, if you had not read up on that as well.
Yea if it works for you, go at it. Especially if you (somehow) know the UIDs you are connecting. Often users would have to look up a UID since they are not-so user controllable (eg: if you put in a big UID it will fail if the zero has not leased it out yet). I do not think(?) the json interface will allow you to upsert. (caveat: I do not use the json mutation method and may be wrong there)