Updating primary key db2


The primary key of EMP is EMPNO; the primary key of DEPT is DEPTNO.



The table with the primary key is called the parent table and the table with the foreign key is called the dependent table (or child table).Referential integrity (RI), therefore, can be defined as a method of ensuring data integrity between tables related by primary and foreign keys.When RI is implemented between tables DB2 will guarantee that an acceptable value is always in each foreign key column based on the data values of the primary key columns.The same constraint name cannot be specified more than once for the same table.

If a constraint name is not explicitly coded, DB2 will automatically create a unique name for the constraint derived from the name of the first column in the foreign key.

For any given referential constraint, the parent table is the table that contains the primary key and the child table is the table that contains the foreign key. The parent table in the employs relationship is the DEPT table. So the primary key (say DEPTNO) resides in the DEPT table and a corresponding foreign key of the same data type and length, but not necessarily the with same column name (say WORKDEPT), exists in the EMP table.