# The DDL Class Declaration

> A class declaration defines a group of related class-elements (or fields) that are stored together. A class declaration consists of class element statements, zero or more access statements, and zero or more event statements with syntax as follows:

>         [compact] [persistent | transient] class class-name {class-elements-list};

> where a class-elements-list consists of:

>         element-statement | access-statement | event-statement;
>         [element-statement | access-statement|event-statement;]
>         […;]

> The element-statement has 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;

> The access-statement has syntax as follows according to the type of index being declared:

>         [voluntary] [unique][inclusive][userdef] tree <class-element | struct-name.element-name | vector-element
>             [asc|desc] [collate collation_name] [,class-element | struct-name.element-name |	vector-element [asc|desc]
>             [collate collation_name]…]>
>         indexname;

> or

>         [userdef] [unique|nonunique] hash <class-element | struct-name.element-name | vector-element
>             [collate collation_name] [,class-element | struct-name.element-name |vector-element
>             [collate collation_name]…]>
>         index-name[expected-number-of-entries];

> or

>         trie < class-element[,class-element] > indexname;

> or

>         trigram < class-element[,class-element] > indexname;

> or

>         [unique] rtree < class-element > indexname;

> or

>         kdtree < class-element[,class-element] > indexname;

> or

>         oid;

> or

>         autoid[number-of-expected-entries];

> or

>         list;

> The event-statement has syntax as follows according to the type of index being declared:

>         event <[[class-element] update | new | delete | delete_all | checkpoint] > event_name [; event-statement ] ;

> where class-element has syntax:

>         element-name| structname

> and vector-element has syntax:

>         vector-name.struct-element | vector-name;

> ## The Compact qualifier

> The `compact` class qualifier limits the total size of the class’ elements to 64K. (That includes not just application data, but also the overhead required by the runtime.)

> Note: The `compact` declaration significantly reduces the overhead that is necessary to maintain the class data (simply put, all references within a class are 2-bytes instead of 4-bytes). It is easy to estimate the total number of references within an object—each `optional`, `vector`, `string`, or `blob` field takes one reference.