Wednesday 18 December 2013

Difference between Surrogate key and Primary key in ax 2009

The difference between the primary key and surrogate key are listed below:

Primary Key: Primary key is a constraint on a column or set of columns in a table. A table can have only one primary key. Primary key ensures that the column(s) are unique and does not allow any NULL values in the column(s). By default, the primary key creates a unique index on the column(s). Primary key is defined on an existing column in the table.

Surrogate key: A surrogate key has multiple names. You can call a surrogate key as artificial key, integer key, non-natural key, synthetic key and so on. Simply put, surrogate keys are integers that are assigned sequentially as needed to populate a dimension table. When creating a table, an additional column is created on the table and a primary key constraint is defined upon that. This new column is populated with sequence values. This is called the surrogate key.
The reason to use a surrogate key solution is to find an efficient way to generate unique sequential numbers.
Surrogate key:
1.    Query processing is fast.
2.    It is only numeric
3.    Developer develop the surrogate key using sequence generator transformation.
4.    Eg: 12453
Primary key:
1.    Query processing is slow
2.    Can be alpha numeric
3.    Source system give the primary key.
4.    Eg: C10999


No comments:

Post a Comment