Key fields

In a database, all records need a unique key. Therefore, it is recommended to create an Id field in every class. This field will contain an automatically generated number for each record. It is not necessary to use this field in particular, or to show it to the user. However, there are numerous situations in which this Id will prove useful.

Any field that will be absolutely unique in a class can also be used as a key field, like a product id. Once your class has a key field, the value is always required. However, we strongly recommend to use a separate field and name it Id

Add key field

When editing the fields of a class in the Blueprint editor, there is a shortcut option Add key field. This automatically creates a new field called Id with the datatype autonumber and the keyfield selector activated for your convenience.

This helps to manage your data properly. The autonumber that is given to every new record can't be changed. It is possible you never use it, but it often proved helpful in maintaining your database properly in the long run.

Create a key field with another data type

Whenever you do want use another field as key field, use the key field checkbox to select the field you wish to use. Please ensure no two records contain the same data in the key field.

Create a compound key field

It can be useful to create a class with two or more key fields. This is only useful when the combination of these fields needs to be unique. In a table person-organization you can create a compound key, consisting of two fields: a field that refers to the person and a field that contains an organization. To select a field as key, go to the details and check 'key field'. see table in the backstage and in the application below

 

 

 

Records with empty key fields are not allowed. When your class has a compound key field, all of the key fields must have a value. After creating a record with a compound key the key fields cannot be edited anymore.