# The DDL Struct Declaration

> The DDL meaning of a struct declaration is exactly the same as a C structure. A structure declaration names a type and specifies an arrangement of elements (called “fields”) of the structure that can have different types. Structures and simple types are used as building blocks to construct database object (class) definitions. Structures can also be used as elements of other structures.

> Note: eXtremeDB structures, in contrast to C or C++ structures, can only be instantiated within a class object; i.e. they exist only as a part of an object of some class.

> Structures are defined with the following syntax:

>         [direct] struct struct_identifier { struct-declaration-list };

> where struct-declaration-list is:

>         type-identifier | struct-name| enum element-name [ = value [, element-name [= value]] …];

> or

>         vector {type-identifier | struct-name} vector-name;

> or

>         [optional]  struct-name element-name;

> ## Direct Structures

> Direct structures (generated by specifying the optional direct keyword) are an efficient optimization that can be applied to fixed sized class layouts.

> ## Optional Structures

> Optional structures (generated by specifying the optional keyword) are stored in the database only when a generated classname_new() transaction is committed. The runtime does not reserve (allocate) space for it within the data layout, except a 2 or 4 byte reference address, until an object is created.