# A DDL Example

> The following sample DDL specification illustrates many of the data types and declarations available:

>         #define int1	signed<1>
>         #define int2	signed<2>
>         #define int4	signed<4>
>         #define uint4	unsigned<4>
>         #define uint2	unsigned<2>
>         #define uint1	unsigned<1>

>         struct SampleStruct {
>             uint2	s1;
>             char<20>	s2;
>         };
>         struct BigStruct {
>             string      str;
>             uint2       u2;
>             uint4       u4;
>             vector     <SampleStruct> vss;
>         };

>         declare database	simple;

>         /* estimated number of class instances is in square brackets */
>         declare OID	SampleStruct[20000];

>         /*
>         * “compact” keyword: Total object size, including overhead is less than 64K.
>         * Size calculation does NOT count size of blob(s) fields
>         * embedded in the class
>         */
>         compact class SampleClass {

>             /* basic data types */
>             uint1 a = 0;
>             uint2 b;
>             uint4 c;

>             /* oid reference */
>             ref	  d;

>             /* vectors - could be made of any type */
>             vector <uint2>        numbers;
>             vector <SampleStruct> ss;

>             /* strings are limited to 64K */
>             string                str;

>             /* blobs are unlimited */
>             blob                  blo;

>             /* optional structure, the value could be missing */
>             optional BigStruct	big_struct;

>             /* voluntary means could be initiated and dropped at runtime
>             * unique    means unique
>             * tree      means tree-based index (sort order is
>             * supported)
>             * hash      means hash-based index
>             * list      means the objects could be sequentially scanned
>             */
>             voluntary unique tree< a,b,ss.s2> SAM;

>             /* estimated number of class instances is in square brackets */
>             hash <a>     AAAA[10000];
>             hash <ss.s2> SSS2[10000];
>             hash <numbers> NNNN[10000];

>             event <new>	new;
>             event <delete> delete;
>             event <a update> update;

>             autoid;
>             oid;
>             list;
>         };

> The database definition file `schema.mco` in most of the SDK samples found in the directory `samples/native/core` give further examples of DDL usage.