The following table describes the data types recognized by the DDL compiler
mcocomp:Data typeMeaningExamplesigned<n>Signed n-byte integer, n = 1, 2, 4, or 8.Example:{ signed<2> a_short; };unsigned<n>Unsigned n-byte integer, n = 1, 2, 4, or 8.Example:{ unsigned<4> hall; };float4-byte real number.Example:{ float rate; };double8-byte real number.Example:{ double rate; };char<n>Fixed length single-byte character array less than 64K in size.charfields could store C-type strings or binary data. Trailing null characters for C strings are not required to be stored, since eXtremeDB adds them when the string is read out of the database, provided that the size of the supplied buffer is large enough to hold it.Example:{ char<8> name; };nchar<n>Fixed length double-byte character array less than 64K in size.ncharfields store 2-byte characters that are sorted by their numerical value. This is suitable for many Asian languages.Example:In the schema:
{ nchar<20> uname; };In the C/C++ program:
nchar_t uname[21];wchar<n>Fixed length double-byte character array of less than 64K in size.wcharfields store Unicode characters that are sorted according to the machine’s locale setting.Example:In the schema:
{ wchar<20> uname; };In the C/C++ program:
wchar_t uname[21];binary<n>Fixed length byte array less than 64K in size. Likechar<n>except in how comparison is performed while building an index or searching. For these purposes an array of characters has the natural delimiter '\0' that marks the end of the compared part;binarydata are used entirely as defined by the array size. Can be a field of a class, structure and even of a direct structure. Arrays andvectorsofbinary<n>are allowed.Example:{ binary<100> b; binary<100> b_array[10]; vector<binary<100>> b_vector; };stringVariable-length single-byte character array of less than 64K bytes in size. Bytes are returned to the application exactly as stored (up to the length of the supplied buffer). C-strings of unknown length should be stored in astringfield to save space. Ending null characters can be omitted, for the same reasons as forchar<n>type. On creation, fields of typestringcontain only a 2 or 4 byte null pointer. No storage is allocated until a value is inserted and the pointer value is set to the address of the variable length storage (which consists of the 2 byte length followed by the body).Example:{ string description; };nstringVariable length double-byte character array less than 64K in size. Seenchar. On creation, fields of typenstringcontain only a 2 or 4 byte null pointer. No storage is allocated until a value is inserted and the pointer value is set to the address of the variable length storage (which consists of the 2 byte length followed by the body).Example:In the schema:
{ nstring uname; };In the C/C++ program:
nchar_t *uname;wstringVariable length double-byte character array less than 64K in size. Seewchar. On creation, fields of typewstringcontain only a 2 or 4 byte null pointer. No storage is allocated until a value is inserted and the pointer value is set to the address of the variable length storage (which consists of the 2 byte length followed by the body).Example:In the schema:
{ wstring uname; };In the C/C++ program:
wchar_t *uname;varbinaryVariable length byte array (like typestringis a variable length character array except for comparison where all bytes of thestringare used). Can be a member of a class or structure (making it variable length). But it cannot be a field of direct structure; can be nullable; arrays andvectorsofvarbinaryare allowed. On creation, fields of typevarbinarycontain only a 2 or 4 byte null pointer. No storage is allocated until a value is inserted and the pointer value is set to the address of the variable length storage (which consists of the 2 byte length followed by the body).Example:{ varbinary vb; varbinary vb_array[10]; vector<varbinary> vb_vector; };enumUser-defined type consisting of a set of named constants called enumerators. The name of each enumerator is treated as a constant and must be unique within the scope of the DDL schema where theenumis defined. An enumerator can be promoted to aunit1, uint2,oruint4value.Example:enum FLOWCONTROL { XON, CTS }; class using_enum { FLOWCONTROL fc; };numeric | decimalnumeric<W,P> =decimal<W,P>; W = width P = Precision where P <= W < 20 The actual storage space occupied is determined by the specified width:
Width Storage Type 1 - 2 signed<1> 3 - 4 signed<2> 5 - 9 signed<4> 10 - 19 signed<8> Example:{ numeric<10,2> num; decimal<8> dec; };sequenceA sequence is an unbounded array of eXtremeDB-supported scalar data elements, e.g. [u]int[1|2|3|4|8], float and double.Example:class quote { sequence<float> open; sequence<float> close; sequence<float> high; sequence<float> low; sequence<int4> volume; sequence< time asc> timestamp; };blobBinary data object; a byte array of any size, can be greater than 64K in size.Example:{ blob jpeg };vectorVariable length array of any data type, such assigned, unsigned,orstruct(in C terminology).Example:struct A { unsigned<2> a1; char a2 }; class A_class { vector <A> struct_array; vector<unsigned<2>> numbers; };refExplicitly declared reference to an object by object’soid.Example:struct Id { unsigned<2> a1; char a2 }; declare oid Id[20000]; class A { ... oid; }; class B { ... ref a; // reference to an // object of class A };Explicitly declared reference to an object by object’sautoid.Example:class A { ... autoid[20000]; }; class B { ... autoid_t<A> a; vector <autoid_t> va; };dateA 32 bit unsigned integer. Though it can be used to store date values in any user-defined format, typically it is used to store the value used in most C/C++ time functions which treat the integer value as the number of seconds since 1 Jan 1970 (Epoch).Example:{ date start_dt; };timeA 32 bit unsigned integer. Though it can be used to store time values in any user-defined format, typically it is used to store the value used in most C/C++ time functions which treat the integer value as the number of seconds since 1 Jan 1970 (Epoch).Example:{ time start_tm; };datetimeA 64 bit unsigned integer. It can store the date/time in higher resolution, up to nanoseconds. To be compatible with Java, C# and xSQL, C/C++ applications must store date/time with database's resolution (defined withMCO_RT_OPTION_DATETIME_PRECISION). Please refer to page Managing Date/Time Fields in C for further details.)Example:{ datetime start_dt; };booleanA fixed size array of bits.Example:{ boolean bits[8]; };rect | rectangleA rectangle with 2,4,8 byte integers, float or double coordinates.Example:{ rectangle <uint2> u2[3]; rectangle<float> f[2]; };
In addition, data types can be fixed size arrays, for example:
time start_tm[3];defines an array of three
timevalues. Any element except vectors, blobs and optional structs can be a fixed size array. Fixed size arrays cannot be used in indexes; for this, use avector.Variable Length Field References
For each
string, vector, sequence, bloboroptional structfield a reference pointer (2 or 4 bytes) is stored in the data layout for the objects of this class. The actual object data is stored separately and retrieved via this reference address when the object is accessed. This can lead to performance considerations especially for persistent databases.String, Blob and Binary Fields
It is recommended to use
blobfields only for large data fields (greater than 1 Kb). When a field is not intended to be used in indexes and its data size is less than 64 Kb it is recommended to usestringfields (without any encoding).Stringfields in eXtremeDB can contain arbitrary data, not only ASCII characters; i.e. arbitrary binary data can be stored in astringwithout encoding. The only limitation is thatstringfields cannot be used in internal comparisons (needed for indexes) and cannot be passed as parameters in xSQL. If a field of binary data is intended to be indexed, thebinaryorvarbinarydata type should be used. Unlikeblobfields,binaryandvarbinaryfields can be added to both simple and compound indexes.