Table Column Type Standard
All table and view column names are in lowercase.
The following column datatypes are used within NEON:
INTEGER
- All of TINYINT (1 byte), SMALLINT (2 bytes), MEDIUMINT (3 bytes), INT (4 bytes) and BIGINT (8 bytes) are used depending on needs.
- They are normally signed (allow both positive and negative numbers) and allow null values.
- All generated Integer columns used as primary key are stored as INT or BIGINT. They guarantee to increase for each new row, but don’t guarantee to be sequential (there can be holes in the series)
- NOTE: Boolean columns are declared and used as BOOLEAN instead of TINYINT
BOOLEAN
- Used instead of TINYINT(1) or BIT(1) to illustrate the boolean true/false purpose.
- 1 represents true and 0 represents false.
- Always declared as NOT NULL.
- Boolean column names always start with is_. For example is_system.
DECIMAL
- All decimal (numeric) values are stored as DECIMAL.
- In most cases defined as size 11,2 (11 digits including two decimals). And normally Nullable.
- NOTE: Non-precise (floating point) datatypes are not used or supported by NEON
DATETIME
- Always stored in UTC. If a different timezone offset is passed in to the API, the value gets converted into UTC before storing in the database. The timezone offset is then lost.
- Always stores time down to millisecond (DATETIME(3))
- Datetime column names are always named as a verb in past tense, for example created or claimed.
VARCHAR (When used as keys)
Most primary and foreign keys are strings rather than generated integers. The following standard applies to string columns used in keys
- Stored as 7 bit ascii
- Only supports letters, digits and underscore. The first character must be a letter. This is to allow the keys to be used as identifiers within NEON scripts
- Always case sensitive (ascii_bin collection)
- Normally max 15 characters.
- The column names always end with _id, for example member_id.
VARCHAR (When used for fixed value columns)
Some columns are enumerations or only allow a value from a predefined fixed set of values. NEON normally uses these column values to control the internal functionality. The most common columns are 'type' and 'state'. The following standard applies to these columns:
- Stored as 7 bit ascii
- Only supports letters, digits and underscore. The first character must be a letter.
- Always case sensitive (ascii_bin collection)
- Normally max 15 characters
- Always mandatory
VARCHAR (When used as alternative keys)
Some functionality allows an alternative custom readable and/or external key to be specified. The most common examples are bizId and entity names.
- Stored as UTF8
- Always unique, just like the primary keys
- Always case sensitive
- Normally max 100 characters
- May or may not be mandatory
VARCHAR (All other cases)
The following applies to normal text columns, for example 'description':
- Uses UTF8 encoding (utf8mb4)
- Normally not case sensitive
- Normally not mandatory. Note that empty strings are ALWAYS stored as NULL. NEON never expects the empty string value ‘’.
- Never allows leading or trailing whitespace
- The length depend on the purpose. For example descriptions are 1,000 characters.
- In some rare cases the datatype TEXT is used instead of VARCHAR, for example to store stack traces. TEXT can however not be defined as a datatype for use by APIs (forms, data list etc)
JSON
Json columns are used heavily within NEON to store:
- Entity configurations
- Dimensions
- Additional business information (the data field)
NEON uses Json columns to provide an extensible, semi-structured data model, however the Json columns must always contain a structure (not a top level array), and are normally only expected to hold one level of information (as in key value pairs). Deeper structures are not searchable through the APIs.
Updated 29 days ago