This section describes the SDL commands pertaining to modules.

Declare an empty module:

Copy
module my_module {}

Declare a module with some content:

Copy
module my_module {
    type User {
        required property name -> str;
    }
}

Define a module corresponding to the more explicit DDL commands.

module ModuleName "{"
  [ schema-declarations ]
  ...
"}"

The module block declaration defines a new module similar to the CREATE MODULE command, but it also allows putting the module content as nested declarations:

schema-declarations

Define various schema items that belong to this module.

Unlike CREATE MODULE command, a module block with the same name can appear multiple times in an SDL document. In that case all blocks with the same name are merged into a single module under that name. For example:

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

module my_module {
    type User extending Named;
}

The above is equivalent to:

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

    type User extending Named;
}

Typically, in the documentation examples of SDL the module block is omitted and instead its contents are described without assuming which specific module they belong to.

It’s also possible to declare modules implicitly. In this style SDL declaration uses fully-qualified name for the item that is being declared. The module part of the fully-qualified name implies that a module by that name will be automatically created in the schema. The following declaration is equivalent to the previous examples, but it declares module my_module implicitly:

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

type my_module::User extending my_module::Named;
Light
Dark
System