Support > Repository > Model > Specify primary key

Be sure to prepare one or more primary key items in the model. "Primary key" is a value that uniquely identifies data, it is a value without duplication.

Click the "details" button on the right side of the item used as the primary key.

Fig. 1 Detailed definition

When "Use as primary key" is checked, this item becomes the primary key. Furthermore, if "Use Sequence" is checked in the "Details of Primary Key" column, a unique number will be automatically assigned from the start number.

Figure 2 Setting the primary key

Click the "OK" button provided at the bottom of this window (window) and close it.

Primary key The key icon is displayed in the model item list for the item specified.

Figure 3 Key icon is displayed

A single item that can uniquely identify data is called a "single key".

Artificial key

When an integer type item is specified as the primary key, the system side can assign serial numbers so that the primary key and value of existing data do not overlap when newly registering data.This is called "artificial key (or proxy key)".

Natural key

The primary key that takes advantage of the characteristics of data is called "natural key".In terms of business characteristics such as employee number and product number, non-overlapping values ​​are used as the primary key.

Those that can uniquely identify data by combining multiple items are called "compound keys". There are ways to combine multiple natural keys, or to combine natural keys and artificial keys.

Even when an artificial key (proxy key) is applied to the primary key,Missing numberMay occur.Specifically, it is the case as follows.

  • For some reason the registration process failed on the database side.
  • I deleted that data.

Some databases increase the numbering performance by keeping some order in memory beforehand, but you may erase the number held in a resultSkip number.

Even if you use database order, missing numbers and jump numbers may occur.For details, please consult a technician familiar with the database to use.
  • It is not possible to change the value of the primary key saved once.
  • When "Use as primary key" setting is checked,Mandatory check is automatically enabled and can not be changed.
  • When the date type item is set as the primary key, only date format "yyyy - MM - dd" is allowed.We can not point out other forms.
  • When the time type item is set as the primary key, only the time format "HH: mm: ss" is allowed.We can not point out other forms.
  • When the date/time type item is set as the primary key, only date format "yyyy - MM - dd HH: mm: ss" is allowed.We can not point out other forms.
  • Compound keys are not supported for model reference and reference linking using check boxes.
  • The reference linkage item can not be the primary key.

Internal representation of compound key 7.8

When using a compound key, the Web form generated by Wagby handles data in the following format.


Where value1, value2 are the values ​​of primary key 1 and primary key 2, respectively."$SEP" is the value delimiter character.

For versions before R7.8, this delimiter is "$".

Related pages

The repository key is model/modelitem/@primaryKey.