Restrict the range (rdfs:range) of a role


#1

it is possible to restrict the range of a role (like rdfs:range), for example, that in the “parent” role only entities of the type “person” can be associated? In graql it would be something like:

person sub entity;
parent sub role;
child sub role;
parentship sub relationship
relates parent
relates child;

parent “must-be-a” person;


#2

No, that is not possible.

A role is never to be defined by itself (i.e. parent sub role;). A role is always expected to relate to a relationship type and be played by some other concept type.

In the example you provided, the relationship type and its roleplayers would be defined like so:

define
  person sub entity,
    plays parent,
    plays child;

  parentship sub relationship,
    relates parent,
    relates child;

#3

Just to clarify. Yes, the type-role mapping restriction is done on the type side, i.e. the playability is specified when a type is defined. Restricting it from the role side- specifying types that a role can play on role definition - is unsupported.

Also, it is possible to define roles by itself, especially when role hierarchies more complex than a single parent-child pair are involved.