Skip to main content

Data Types

XINA has a fixed set of data types which apply to attributes and fields. They are intended to provide consistent behavior across MySQL, Java, and JavaScript data types.

Numeric Types

TypeJavaMySQLJavaScriptNotes
int(1)bytetinyintnumberinteger, -28 to 28-1
int(2)shortsmallintnumberinteger, -216 to 216-1
int(4)intintnumberinteger, -232 to 232-1
int(8)longbigintnumberinteger, -264 to 264-1 ⚠️
float(4)floatfloatnumberIEEE 754 4 byte floating point
float(8)doubledoublenumberIEEE 754 8 byte floating point
booleanbooleantinyintbooleanMySQL treats 0 as false, non-zero as true

⚠️ JavaScript number is 8 byte float, so only -253 to 253-1 is stored with exact precision


Character Types

Character data types offer two encoding options:

  • UTF-8 - default encoding, variable length, 1 to 4 bytes per character
  • ASCII - subset of UTF-8, fixed length, 1 byte per character

Two SQL types:

  • char(n) - data stored in the table, fastest search and index, uses fixed amount of space per row (n * max_bytes_per_character)
  • varchar(n) - data stored in the table, fast search and index, uses variable amount of space per row (up to n * max_bytes_per_character)
  • text - data stored outside the table, slower search and index, uses only as much space as needed

Two general types:

  • string - text is normalized before insertion
    • leading and trailing whitespace is trimmed
    • all internal whitespace is reduced to a single space character
  • text - text is inserted as provided

Note, all string operations are case-insensitive by default. This can be overridden with the collate expression by specifying a binary collation.

TypeJavaMySQLJavaScriptNotes
utf8string(n)stringchar(n)stringn up to 128, uses n*4 bytes, normalized
utf8vstring(n)stringvarchar(n)stringn up to 128, uses up to n*4 bytes, normalized
utf8stringstringmediumtextstringup to 224 bytes, normalized
utf8textstringmediumtextstringup to 224 bytes, not normalized
asciistring(n)stringchar(n)stringn up to 256, uses n bytes, normalized
asciivstring(n)stringvarchar(n)stringn up to 256, uses up to n bytes, normalized
asciistringstringmediumtextstringup to 224 bytes, normalized
asciitextstringmediumtextstringup to 224 bytes, not normalized

Temporal Types

Temporal data types store time data. There are two categories of temporal types:

  • instants - identify specific moment in time, independent of time zone
    • stored numerically in the database in milliseconds
    • datetime and date use Unix epoch
    • datetime and date comparable in database
    • date + time = datetime
    • typically displayed in local time zone in front-end applications
  • timestamps - identify specific formatted time without time zone consideration (thus local)
    • stored as ISO 8601 formatted string in database
    • localdate and localdatetime comparable in database
    • CONCAT(localdate, 'T', localtime) = localdatetime
TypeJavaMySQLJavaScriptNotes
datetimeDateTimebigintdateinstant with millisecond precision, as Unix time
dateXDatebigintdateinstant at start of date UTC, as Unix time
timeLocalTimeintnumberlength of time up to 23:59:59.999, as millisecond count
localdatetimeLocalDateTimechar(24)stringfull timestamp without timezone, stored as string
localdateLocalDatechar(10)stringdate without timezone, stored as string
localtimeLocalTimechar(12)stringlength of time up to 23:59:59.999, as string

JSON Types

JSON data types store JSON data directly in the database.

TypeJavaMySQLJavaScript
jsonJsonValuejson*
jsonarrayJsonArrayjsonarray
jsonobjectJsonObjectjsonobject