Officially out now: The TypeDB 3.0 Roadmap >>

relates statement

The statement <RELATION LABEL> relates <LABEL> is used to identify the <LABEL> as a role type related by <RELATION LABEL>.

Defining role types

The relates keyword can be used to define a role type for a relation type.

define parentship relates parent;

Undefining role types

The relates keyword can be used to undefine a role type from a relation.

undefine relates parent from parentship;

Matching

The relates keyword can be used to match all role types related by a relation type.

match parentship relates $r;

Matching relation types

The relates keyword can be used to match all relation types for a role type with a label <LABEL>.

match $r relates parent;

Note that a scope can be used to have more specific results. The previous query can return results for different role types with the same <LABEL>, while the following example returns only relation types with the specified scope.

match $r relates parentship:parent;