Updating primary key db2 Hookup toledo ohio
Acceptable is defined in terms of an appropriate value as recorded in the corresponding primary key, or a null.
Two other important RI terms are parent and child tables.
The referential constraint ties the primary key to the foreign key.
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).
The primary key of EMP is EMPNO; the primary key of DEPT is DEPTNO.
Several foreign keys exist, but let's examine the foreign key that relates EMP to DEPT.
This should be done to ensure entity integrity regardless of whether dependent tables are related to the table being defined.
A referential constraint consists of three components: a constraint name, the columns comprising the foreign key and a references clause.Automatically enforcing DB2 data integrity is usually a wise choice of action because it offloads such work from application programs.Additionally, DB2-enforced data integrity will be applied for both planned and ad hoc modifications.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.
As a general rule of thumb it is a good physical design practice to implement referential integrity using database constraints instead of trying to program integrity into application programs.
The rules that accompany the RI definition are just as important as the relationship to ensure correct and useful DB2 databases.