Monday 20 June 2016

Surrogate Key, Replacement Key, Alternate Key in Ax 2012

Surrogate Key
                              surrogate key is the auto-generated primary key for a table in the database.
The surrogate key is linked to the already existing RecId field within any table. 

  • The surrogate key is a unique 64-bit integer value that is mandatory for the table and cannot be changed or have duplicates
  • It's something created by the database itself, like an identity column, however in Ax it's managed by the kernel.
eExample  https://community.dynamics.com/ax/b/axrajdipdas/archive/2013/04/16/how-to-create-and-implement-of-surrogate-keys-in-ax2012
      
      Replacement Key
             
            While a surrogate key is great for lookup and database performance, it is not useful for the end user because it gives no indication of the table’s purpose, or what related tables it is linked to. For this reason AX 2012 has added the ‘Replacement Key’ index property for tables. 
              The replacement key index is a dropdown of alternate keys that have been specified for the table. There can be any number of alternate keys for a table but only a single replacement key. More than one field can be specified under a replacement key, and it is these fields that will be displayed to the end user on a form instead of the surrogate key field.

     Alternate Key
               A table can have any number of alternate keys. An alternate key may be a natural key or a single field primary key used in foreign or primary key relations with other tables. In either case, to set one, the user must create a new index and then set AllowDuplicates to “No” and AlternateKey to “Yes”. If AllowDuplicates is not set to “No” then AlternateKey should be greyed out and uneditable.










No comments:

Post a Comment