plays statement

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

Schema for the following examples
#!test[schema, commit]
define
relation parentship, relates parent, relates child;
entity user, plays parentship:child;

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.

#!test[schema]
define user plays parentship:parent;

Undefining role players

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

#!test[schema]
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.

#!test[schema]
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>.

#!test[schema]
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.

#!test[schema]
match $rp plays parentship:parent;