@key
annotation
The @key
annotation is used
to specify key attributes for entities and relations.
Syntax
<type label> owns <attribute type label> @key;
The @key
annotation does not accept any arguments.
Usage
The @key
annotation is used to mark an owned attribute as a key, which in fact declares two constraints:
-
The unique constraint as an equivalent of
@unique
. -
The cardinality constraint as an equivalent of
@card(1)
.
For example, the following statement declares that any content
should have exactly one key id
with a unique (across all content
s) value:
define
entity content owns id @key;
attribute id value string;
Subtyping
Refer to unique constraint subtyping and card constraint subtyping for the respective constraints' subtyping behavior.
Limitations
Cannot be used with the @unique
annotation the @card
annotation as it produces same constraints.
See unique
annotation supported value types for the list of supported value types.