Usage of Keys in Business Central:
Dynamics 365 BC application use SQL database. SQL database uses keys to identify records in the table. It also uses indexes to speed up the performance of table data.
In AL, a key is a sequence of one or more field IDs from a table. There are two types of Keys in AL i.e.
(1) Primary Key- Primary Key is a unique key. It is only one in a table. It cannot be defined in the table extension.
(2) Secondary Key- Secondary Key created indexes in SQL. It can be multiple of 40 (including Primary Key). It can define in both Table objects and table extension objects.
(3) The clustered property isn’t supported in table extension objects.
(4) The unique property isn’t supported in table extension objects.
Defining new Keys:
The total number of keys in a table is 40.
Points to be Remember when a modification in the key is made:
- Don’t delete primary keys.
- Don’t add or remove primary key fields, nor change their order.
- Don’t change properties of existing primary keys.
- Don’t add more unique keys.
- Don’t add more clustered keys.
- Don’t add keys that are fields of the base table.