Links

This section describes the SDL declarations pertaining to links.

Declare an abstract link “friends_base” with a helpful title:

abstract link friends_base {
    # declare a specific title for the link
    annotation title := 'Close contacts';
}

Declare a concrete link “friends” within a “User” type:

type User {
    required property name -> str;
    property address -> str;
    # define a concrete link "friends"
    multi link friends extending friends_base-> User;

    index on (__subject__.name);
}

Any time that the SDL declaration refers to an inherited link that is being overloaded (by adding more constraints or changing the target type, for example), the overloaded keyword must be used. This is to prevent unintentional overloading due to name clashes:

abstract type Friendly {
    # this type can have "friends"
    link friends -> Friendly;
}

type User extending Friendly {
    # overload the link target to be User, specifically
    overloaded multi link friends -> User;
    # ... other links and properties
}

Define a new link corresponding to the more explicit DDL commands.

Concrete link form used inside type declaration:
[ overloaded ] [{required | optional}] [{single | multi}]
  link name
  [ extending base [, ...] ] -> type
  [ "{"
      [ default := expression ; ]
      [ readonly := {true | false} ; ]
      [ on target delete action ; ]
      [ annotation-declarations ]
      [ property-declarations ]
      [ constraint-declarations ]
      ...
    "}" ]


Computable link form used inside type declaration:
[{required | optional}] [{single | multi}]
  link name := expression;

Abstract link form:
abstract link name [extending base [, ...]]
[ "{"
    [ readonly := {true | false} ; ]
    [ annotation-declarations ]
    [ property-declarations ]
    [ constraint-declarations ]
    [ index-declarations ]
    ...
  "}" ]

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

annotation-declarations

Set link annotation to a given value.

property-declarations

Define a concrete property on the link.

constraint-declarations

Define a concrete constraint on the link.

index-declarations

Define an index for this abstract link. Note that this index can only refer to link properties.