# `@key` annotation

The `@key` annotation is used to specify key attributes for entities and relations.

## [](#_syntax)Syntax

Syntax

```typeql
<type label> owns <attribute type label> @key;
```

The `@key` annotation does not accept any arguments.

## [](#_usage)Usage

The `@key` annotation is used to mark an owned attribute as a key, which in fact declares two constraints:

*   The [unique](../unique/index.md) constraint as an equivalent of `@unique`.
    
*   The [cardinality](../card/index.md) 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:

```typeql
#!test[schema]
define
  entity content owns id @key;
  attribute id value string;
```

### [](#_subtyping)Subtyping

Refer to [unique constraint subtyping](../unique/index.md#subtyping) and [card constraint subtyping](../card/index.md#subtyping) for the respective constraints' subtyping behavior.

## [](#_limitations)Limitations

Cannot be used with the [`@unique` annotation](../unique/index.md) and the [`@card` annotation](../card/index.md) as it produces same constraints.

See [`unique` annotation supported value types](../unique/index.md#_value_types) for the list of supported value types.

[@abstract](../abstract/index.md) [@subkey](../subkey/index.md)

[Edit on GitHub](https://github.com/typedb/typedb-docs/edit/3.x-development/typeql-reference/modules/ROOT/pages/annotations/key.adoc) Edit this page on GitHub.