Relationships
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
Dgraph stores relationships
among nodes
to represent graph structures, and
also stores literal properties of nodes
.
This makes it easy for Dgraph to ingest the RDF N-Quad format, where each line represents
Node, RelationName, Node, Label
orNode, RelationName, ValueLiteral, Label
The first represents relations among entities (nodes in graph terminology) and the second represents the relationship of a Node to all it’s named attributes.
Often, the optional Label
is omitted, and therefore the N-Quad data is also
referred to as “triples.” When it’s included, it represents which Tenant
or
Namespace
the data lives in within Dgraph.
Dgraph can automatically generate a reverse relation. If the user wants to run queries in that direction, they would need to define the reverse relationship
For Relationships
, the subject and object are represented as 64-bit numeric
UIDs and the relationship name itself links them:
<subjectUID> <relationshipName> <objectUID>
.
For literal attributes of a Node
, the subject must still (and always) be a
numeric UID, but the Object will be a primitive value. These can be thought of
as <subjectUID> <relationshipName> <value>
, where value is not a 64-bit UID,
and is instead a: string, float, int, dateTime, geopoint, or boolean.
Was this page helpful?