Types of Field Definitions

Field definitions describe the format of the data that will be stored in the space.

A valid space definition must contain at least one field definition. Field definitions are created by the FieldDef’s create() method, and can be put (or taken) from space definitions. Field definitions can also be reused and put into as many space definitions as needed (for example when using some fields as foreign keys to correlate tuples stored in different spaces).

A field definition is created by using the FieldDef's create() method. A field definition has two mandatory attributes which are provided to the create() method: a name and a type.

The field name is a string and must start with a letter (upper or lower case) character and then contain any combination of letters (upper or lower case) and numbers, or special characters or symbols such as "-" or "_" or "$".

Tip: Field names are case-sensitive.

The field type must be one of those described in the following table.

Type Description
BLOB A BLOB (binary large object) type is an array of 8 bit values.
BOOLEAN The BOOLEAN type has one of two values, true or false, represented by the integers 1 or 0, respectively.
CHAR Char type represents a char.
DATETIME Datetime type represents a date. Two date formats are supported:
  • Julian Calendar
     Any date 64-bit time value
  • Proleptic Gregorian Calendar
     1 A.D. to 64-bit time value.
DOUBLE Double type represents double.
FLOAT Float type represents float.
INTEGER Integer type represents a int.
LONG Long type represents a long.
SHORT Short type represents a short.
STRING String type represents string.

A field definition’s name and type can be retrieved using the FieldDef object’s getName and getType methods.

Beyond the field’s name and type, a field definition also has the following optional boolean attribute:

Optional (nullable) field
 You can use the FieldDef object’s setNullable method to specify if the field can be null or not (defaults to false), which marks that field as optional, and use the isNullable to test if the field is optional or not. The equivalent functions in the C API are tibasFiledDefSetNullable() and tibasFieldDefIsNullable().