TypeDB 3.0 is live! Get started for free.

has statement

The statement <OWNER VAR> has <ATTRIBUTE VAR> is used to identify the <OWNER VAR> as owning the <ATTRIBUTE VAR>.

Inserting attribute ownership

The has keyword can be used to attach an attribute to an object.

insert $person has $name;

An attribute can be created in-place by providing its type and value.

insert $person has name "Alice";

Deleting attribute ownership

The has keyword is used to remove an attribute from its owner.

delete has $name of $person;

Matching attributes

The has keyword can be used to match attributes of an object.

match $person has $name;

The attribute type may be provided.

match $person has name $name;

The attribute can be matched by attribute type and value instead of binding it to a variable.

match $person has name "Alice";

Alternatively, a comparison can be used to constrain the attribute value.

match $person has name < "Bob";