Tuesday, August 30, 2011

Surrogate Key

It's a system generated key which is not actual defined primary but work as a primary key in a table.For example in employee table we have employee number as an actual primary key, as it uniquely identifies all records in employee table. But rownum is system generated key, Oracle application generates by default one row number for each record in relational table. This row num can be used as primary key. In Informatica ETL tool we use sequence generator to generates sequences (surrogate keys). For example let's relational table has one record for employee number 101. We have one field like address for this column. Suppose tomorrow employee has three addresses. We can not increase number of fields for each record every time as it will cost. Now system will not allow for having 3 records for same emloyee id(Primary key violation). So we will generate 3 sequences for these three reocrds. Primary key constraint will be set on sequece no rather than on employee id. It's usual to have surrugate key data type as decimal. it's so because we can generate any number of desired sequences by incrementing (Arthmetic operation) existing one.

No comments:

Post a Comment