How table indexes are looking in the SQL layer for F&O?
Definitions:
Index
– data structure that improves the speed of data retrieval
– are used to quickly locate data without having to search every row in a database table every time a database table is accessed
– is the way to get an unordered table into an order that will maximize the query’s efficiency while searching
Unique index
– is the index that helps maintain data integrity by ensuring that no two rows of data in a table have identical key values
Clustered index
– is an index that defines the physical order in which table records are stored in a database
– by default a clustered index is created on a primary key column
– since there can be only one way in which records are physically stored in a database table, there can be only one clustered index per table
Primary index
– is an index on a set of fields that includes the unique primary key for the field and is guaranteed not to contain duplicates
– primary key is not necessarily clustered index (although probably in 95% of scenarios it is), while Clustered index is not necessarily is primary key
Surrogate key
– a surrogate key is any column or set of columns that can be declared as the primary key
– a surrogate is a candidate key
– the most common type of surrogate key is an incrementing integer, such as RecId
Alternate key
– a table can have several alternate keys
– any one alternate key can switch to being the primary key
– in practice each alternate key relies on a unique index for its implementation and enforcement
Replacement key
– 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
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/image-1024x767.png)
Scenario:
•Ax table: DRVCarsTable
•Table fields: Brand, Model, CarId, PollutionStandard, Color, …
•Indexes:
•Unique indexes
•ReplacementKey: Brand, Model
•CarIdx: CarId
•Non unique index
•PollutionStandardIdx: PollutionStandard
•SurrogateKey
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/32312312312-1-1024x633.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/31231231-1-1024x666.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/1-1024x595.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/2222-1024x623.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/3-1024x596.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/4-1024x624.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/5-1024x611.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/6-1024x625.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/7-1024x620.png)
Special property: Create RecId index: NO
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/8-1024x613.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/9-1024x569.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/10-1024x540.png)
Non-Unique indexes
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/11-1024x561.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/12.png)
SQL change tracking
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/13-1024x559.png)
![](http://dynamicsrocks.com/wp-content/uploads/2022/06/14-1024x591.png)