New ACM paper, free-tier cloud, and open-source license


The @unique keyword is an annotation, that can be used with an owns statement to specify, that the selected attribute type must be uniquely owned by data instances of a given type.


The syntax of a @unique statement includes:

<type> owns <attribute-type> @unique;


TypeQL statements with the @unique keyword can be used only in Define queries.

The @unique keyword adds a uniqueness constraint for all attributes of the attribute type owned by data instances of the subject type.

A uniqueness constraint means that every attribute of an attribute type can be owned by no more than one data instance of the subject type. That makes every owned attribute unique among all data instances of the subject type.

Usage in a schema definition

For this example, use a database with the IAM schema and sample data loaded.

Since in Define and Undefine queries you can’t use variables, both subject and object of an owns statement can only be type labels.

For example, to define that the object type owns the object-type attribute type with the @unique annotation, use:

Define unique query example
object sub entity, owns object-type @unique;

Learn more

Learn more about type statement in TypeQL.

Learn about types in TypeQL.

Provide Feedback