Object Types

This section describes the SDL declarations pertaining to object types.

Consider a User type with a few properties:

type User {
    # define some properties and a link
    required property name -> str;
    property address -> str;

    multi link friends -> User;

    # define an index for User based on name
    index on (__subject__.name);
}

An alternative way to define the same User type could be by using abstract types. These abstract types can then be re-used in other type definitions as well:

abstract type Named {
    required property name -> str;
}

abstract type HasAddress {
    property address -> str;
}

type User extending Named, HasAddress {
    # define some user-specific properties and a link
    multi link friends -> User;

    # define an index for User based on name
    index on (__subject__.name);
}

Introducing abstract types opens up the possibility of polymorphic queries.

Define a new object type corresponding to the more explicit DDL commands.

[abstract] type TypeName [extending supertype [, ...] ]
[ "{"
    [ annotation-declarations ]
    [ property-declarations ]
    [ link-declarations ]
    [ constraint-declarations ]
    [ index-declarations ]
    ...
  "}" ]

The core of the declaration is identical to CREATE TYPE, while the valid SDL sub-declarations are listed below:

annotation-declarations

Set object type annotation to a given value.

property-declarations

Define a concrete property for this object type.

constraint-declarations

Define a concrete constraint for this object type.

link-declarations

Define a concrete link for this object type.

index-declarations

Define an index for this object type.