Officially out now: The TypeDB 3.0 Roadmap >>

plays statement

The statement <LABEL> plays <SCOPED ROLE LABEL> is used to identify the <LABEL> type as a roleplayer of <SCOPED ROLE LABEL>.

Defining roleplayers

The plays keyword can be used to define a type as a roleplayer of a role type. Note that a scope is required to resolve role type names ambiguity.

define user plays parentship:parent;

Undefining roleplayers

The plays keyword can be used to undefine a type’s role.

undefine plays parentship:parent from user;

Matching

Matching played role types

The plays keyword can be used to match all role types a type plays.

match user plays $r;

Matching roleplayer types

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

match $rp plays 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 $rp plays parentship:parent;