# DDL Element Statements

> Element statements are used to define the elements or fields of a class and have syntax as follows according to the type of field being declared:

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

> or

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

> or

>         [optional]  struct-name element-name;

> Element statements declare field names with their types and possibly a default value. Fields of type integer, float, date, and enum can have default values expressed in the schema. Default values will be assigned to such fields when a new record of the type is created in the database and no explicit value is ‘put’ in the field. However note that string and char type fields cannot be assigned a default value.

> Fields of type struct can be declared as optional. An optional declaration means that the field may or may not be actually stored in the database. If the field is not stored, the runtime does not reserve (allocate) space for it within the data layout (except the 2/4 byte reference) and the associated “get” methods will return a null pointer.

> The following example illustrates a variety of element statements for class Everything (note the default values for fields fc and u2):

>         struct Id
>         {
>             uint4 seq;
>         };
>         struct Item
>         {
>             uint4     id;
>             string    name;
>         };
>         enum FC_ {
>             XON,
>             CTS
>         } flow_control;

>         declare database  simple;
>         declare OID       Id[20000];

>         class Everything
>         {
>             date 		e_date[7];
>             time 		e_time[12];
>             flow_control	fc = XON;
>             uint2 		u2 = 99;
>             nullable uint4	u4, h;
>             blob  		blo;
>             string          c;
>             vector<uint2>   vint;
>             vector<string>  vs;
>             vector<Item>	is;
>             optional Item	alternate;
>         };

> Note: In an element statement such as

>         nullable uint4	u4, h;

> the nullable attribute applies to both fields u4 and h.

> Any field type can be declared nullable. The nullable attribute adds one byte of overhead (for a null indicator field).