Inspired_Blue
Inspired_Blue

Reputation: 2438

How to query role types in a TypeDB relation?

Suppose I have the following in the schema:

define

person sub entity, plays employment:employee;
company sub entity, plays employment:employer;
employment sub relation, relates employee, relates employer;

Then it imposes the restriction that employer must be of type company and employee must be of type person.

How do I find about this restriction through a query?

So far the best that I know is:

match $x sub relation; get $x;

It does show that employment is a relation. But it doesn't show the role types that are allowed/ permitted. How to query that?

Upvotes: 1

Views: 223

Answers (1)

2bigpigs
2bigpigs

Reputation: 462

match $x sub relation; 
$x relates $y;
get $x, $y;

You can use the same constructs for querying the schema (or data) as you did to write it. So you can also find which types play the roles through the query:

match $x sub relation; 
$x relates $y;
$z plays $y;
get $x, $y, $z;

Upvotes: 2

Related Questions