106 | Chapter 4: Oracle Data Structures
Foreign key
The foreign key constraint is defined for a table (known as the child) that has a
relationship with another table in the database (known as the parent). The value
entered in a foreign key must be present in a unique or primary key of another
specific table. For example, the column for a department ID in an employee
table might be a foreign key for the department ID primary key in the department
table.
A foreign key can have one or more columns, but the referenced key must have
an equal number of columns. You can have a foreign key relate to the primary
key of its own table, such as when the employee ID of a manager is a foreign key
referencing the ID column in the same table.
A foreign key can contain a NULL value if it??™s not forbidden through another
constraint.
By requiring that the value for a foreign key exist in another table, the foreign
key constraint enforces referential integrity in the database. Foreign keys not
only provide a way to join related tables but also ensure that the relationship
between the two tables will have the required data integrity.
Pages:
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249