Can't understand doc section "giving nodes a type"

I’m new to graph databases. I got through the dgraph tour and I’m in the process of creating my own schema.

I’m having a hard time understanding this section of the doc: https://docs.dgraph.io/howto/#giving-nodes-a-type

The natural language sentence “associate each type of node with a particular predicate. E.g. type foo is associated with a predicate foo” makes no sense to me. I must be missing some knowledge.

Could someone share a schema definition example? Graphql / query

The idea here is that its best if you have a unique predicate that you expect all nodes of a type to have.

For example, say all nodes of type Person can have person_name. Then you could get all nodes of type person by doing a has(person_name) query at root. Similarly, say you have an order and you know all orders must be related to some order_items then that becomes the unique predicate which defines orders. This is better than having a Type edge on all your nodes for the reasons mentioned in the docs.

1 Like

Ok got it. It’s a sort of duck typing. “If it behaves = has predicates like a duck, it’s a duck”

Coupled with predicate naming conventions like _:Pawan <person.name> "Pawan" ., it makes sense to me now.

Find all persons: has(person.name)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.