Tuesday, January 8, 2019

Understanding Replacement key, Alternate key,Surrogate key,

WHAT IS A SURROGATE KEY?
In AX 2012, a 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. This means that the surrogate key is a unique 64-bit integer value that is mandatory for the table and cannot be changed or have duplicates. The fact that it is a 64-bit integer (int64) value means table operations normally perform faster than other types of field such as string fields. This is the main strength of surrogate keys.

WHAT IS A REPLACEMENTKEY INDEX?
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.

A replacement key is an alternate key that the system can display on forms instead of a meaningless numeric primary key value. Each table can have a maximum of one replacement key.


The replacement key is chosen by setting the ReplacementKey property on the table. The drop-down list offers every alternate key as an available value.


Steps while creating a replacement key 

1.Create a index with with properties AllowDuplicates to No and AlternateKey to Yes




2.Assign Primary index as surrogate key and Recplacement key as Index which we created.





3.Create a Primary key based foreign key relation on the Child Table.




4. A primary key based reference will be created on the Table and it reflects a RecId of the primary table.





5.Add a reference group column on the Form and assign the reference field to it.




6.It reflects the Field or shows the drop down with the fields present in the Index which is assigned a replacement key on the primary table. 






WHAT IS AN 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


3 comments:

  1. Thanks for sharing this.,
    Leanpitch provides online training in Scrum Master during this lockdown period everyone can use it wisely.
    Join Leanpitch 2 Days CSM Certification Workshop in different cities.

    certified scrum master certification cost

    ReplyDelete
  2. Thanks for sharing this.,
    Leanpitch provides crash course in Facilitating change everyone can use it wisely.

    Reducing barrier for change

    Facilitating change

    ReplyDelete
  3. Amazing knowledge and I like to share this kind of information with my friends and hope they like it they why I do.. check this link

    ReplyDelete

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...