Axaptapedia is now maintained by AgileCadence For more information please click here.

Surrogate key

From Axaptapedia
Jump to: navigation, search

A surrogate key is a computer-generated (non meaningful) record identifier. In Dynamics Ax terms, it is a RecId field, used as the primary key of a table.

Introduction[edit]

Prior to Ax 2012, it was possible to use a RecId-based field as the primary key of a table (and therefore as the foreign key in a related table), but this caused difficulties with forms and reports as the RecId value is not meaningful to users when shown in the user interface. Due to this, it was not considered best practice to use the RecId as a primary key except in particular circumstances.

In Ax 2012 the concept of surrogate keys was introduced. This introduced a mechanism by which RecId-based fields could be used as primary keys without the disadvantage described above.

Foreign key replacement[edit]

When a foreign key on a table is based on the surrogate primary key of a related table, using the new foreign key relation type, kernel-supported alternative key support is available on forms based on the table containing the foreign key. This is known as Foreign key replacement.

Using an automatic replacement mechanism, one or more fields from the related table can be shown on a form in place of the RecId field which is actually stored.