Parent key columns
A parent key is either a primary key or a unique key in the parent table of a referential constraint. This key consists of a column or set of columns. The values of a parent key determine the valid values of the foreign key in the constraint.
If every row in a table represents relationships for a unique entity, the table should have one column or a set of columns that provides a unique identifier for the rows of the table. This column (or set of columns) is called the parent key of the table. To ensure that the parent key does not contain duplicate values, you must create a unique index on the column or columns that constitute the parent key. Defining the parent key is called entity integrity, because it requires each entity to have a unique key.
In some cases, using a timestamp as part of the key can be helpful,
for example when a table does not have a natural
unique key
or if arrival sequence is the key.
- Table
- Key Column
- Employee table
- EMPNO
- Department table
- DEPTNO
- Project table
- PROJNO
PROJNO | PROJNAME | DEPTNO |
---|---|---|
MA2100 | WELD LINE AUTOMATION | D01 |
MA2110 | W L PROGRAMMING | D11 |
PROJNO | ACTNO | ACSTAFF | ACSTDATE | ACENDATE |
---|---|---|---|---|
AD3100 | 10 | .50 | 1982-01-01 | 1982-07-01 |
AD3110 | 10 | 1.00 | 1982-01-01 | 1983-01-01 |
AD3111 | 60 | .50 | 1982-03-15 | 1982-04-15 |