Column naming convention
Each column in the LN data dictionary corresponds to one or more columns in a SQL Server table.
The rules for column names are:
-
General
When an LN column name is created in the SQL Server, it is preceded by the string t_. For example, the LN column with the name cpac is created in the SQL Server with the name t_cpac. By preceding column names by t_, reserved word collisions are avoided. If an LN column name contains a period [.], the period is replaced by the underscore [_] character.
-
Long string columns
SQL Server data type CHAR has a limit of 8000 characters. When an LN string column exceeds this limit, the column is split into segments with a maximum of 8000 characters each. The first 8000 characters are mapped to a column where the name of the column is extended with _1. The next 8000 characters are mapped to a column with a name extended by _2, and so on until all the characters of the string are mapped to a column. For example, if an LN string column called desc contains 8888 characters, these two SQL Server columns are created:
- t_desc_1: size 8000
- t_desc_2: size 888
-
Array columns
In the LN data dictionary, array columns can be defined. An array column is a column with multiple elements in the column. The number of elements is called the depth. For example, a column containing a date can be defined as an array of three elements—a day, a month, and a year. In SQL Server, the three elements of the array column are placed in separate columns. The names of these columns include a suffix with the element number. For example, an array column called date becomes:
- t_date_1: element 1
- t_date_2: element 2
- t_date_3: element 3
Note that if the element is of type string and one element type exceeds the maximum SQL Server character size, it is split. For example:
- t_str_1_1: element 1, part 1
- t_str_1_2: element 1, part 2
-
Array compression
The maximum number of columns in a SQL Server is 1024 columns. If the number of LN columns exceeds the maximum number allowed in SQL Server, the database driver tries to compress (concatenate) array columns to reduce the total number of columns in the table. All elements of one array column can be stored as one column in the SQL Server table with the elements concatenated in binary format. The driver starts by compressing the array column that yields the highest number of columns. It continues compressing array columns until the number of columns is less than the maximum allowed. The name of the compressed column in the SQL Server follows the same convention used for the other columns. For example:
- t_array: contains all elements of the compressed column.