TypeDB 3.0 is live! Get started for free.

plays statement

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

Defining role players

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

define user plays parentship:parent;

Undefining role players

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 role player types

The plays keyword can be used to match all role player 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;