TypeDB 3.0 is live! Get started for free.

links statement

The statement <RELATION VAR> links (<ROLE>: <PLAYER VAR> [ , …​ ]) is used to identify the <PLAYER VAR> as playing <ROLE> in the <RELATION VAR>.

Inserting a role player

The links keyword can be used to attach a role player to a relation instance.

insert $friendship links (friend: $person);

Multiple role players can be attached in the same statement.

insert $friendship links (friend: $alice, friend: $bob);

Deleting a role player

The links keyword is used to remove a role player from a relation instance.

delete links ($person) of $friendship;

Multiple role players can be removed in the same statement.

delete links ($alice, $bob) of $friendship;

Matching role players

The links keyword can be used to match relations along with their role players.

match $friendship links (friend: $person);

The role specifiers may be variables as well.

match $friendship links ($role: $person);

Note that the role label is not required.

match $friendship links ($person);

If a relation binding is not required, the relation type shorthand can be used directly instead.

match friendship ($alice, $bob);