Officially out now: The TypeDB 3.0 Roadmap >>

@abstract annotation

The @abstract annotation is used to specify that a type is abstract.

Syntax

Syntax
<type label> @abstract;

The @abstract annotation does not accept any arguments.

Usage

When defined for a type, the @abstract annotation enforces the abstract constraint, making the type abstract. An abstract type cannot be a direct type for an instance. Thus, a concrete subtype is required for instances creation, and an abstract type can be used as a query target to retrieve information about its subtypes.

define
  entity element @abstract;

Subtyping

The abstract constraint is not inherited. This means all subtypes of an abstract type are concrete by default, enabling the creation of their instances. However, it is possible to define an abstract subtype of an abstract type.

define
  attribute id @abstract, value string;
  attribute page-id @abstract, sub id;
  attribute username sub page-id;

It is impossible to define an abstract subtype of a concrete type.

Wrong definition!
define
  attribute categorized-username @abstract, sub username;

Specialization of role types

Similarly, abstract role types cannot be instantiated. A concrete sub role type can be defined using specialization (keyword as).

define
  relation interaction @abstract,
    relates subject @abstract,
    relates content;

  relation viewing sub interaction,
    relates viewer as subject,
    relates viewed as content;