Foreign Keys Wizard (Oracle)
Go Up to Oracle Object Wizards
A foreign key value in one table (child table) refers to a primary key value in another table (parent table). For example, the Author Name column in a publisher’s database may be the primary key for a table of addresses that includes the Author Name column. If an author isn’t included in the parent table, you can’t add the address to the dependent address table. So foreign keys enforce referential integrity between tables by verifying the existence of foreign key values in the parent table before letting you insert or update foreign key values in the child table. In other words, a foreign key is an integrity constraint that requires each value in one table’s column to match a value in a related table’s data.
To create a new foreign key using a wizard:
- Open a creation wizard for a foreign key. For details, see Opening an Object Wizard.
- Use the following topics as a guide to setting properties and performing tasks as you pass through the wizard panels:
- Properties panel - Foreign Keys (Oracle) - Properties.
- Column Mapping panel - Foreign Keys (Oracle) - Column Mapping.
- DDL View panel - for details, see Previewing the DDL Generated to Create the New Object.
- Finally, use the Execute button to create the object.
Foreign Keys (Oracle) - Properties
When creating or editing a foreign key, this tab/panel lets you work with the following settings:
Setting | Description |
---|---|
Table Owner |
The owner of the table where the foreign key is being created. |
Table Name |
This is the table where the foreign key link originates--the child table. |
Name |
Lets you select a constraint name. System Generated Name - DB2 automatically generates a name. User Specified Constraint Name - You type the name. |
Enabled |
Enable or disable the foreign key. Enabled ensures that all data modifications to a given table (or tables) satisfy the conditions of the constraints. When disabled, the constraint is temporarily not operational. |
Delete Rule |
Select an action: NO ACTION - ensures that referenced values cannot be updated or deleted if to do so would violate referential integrity. CASCADE permits a referenced row in a child table to be deleted/updated if it is deleted/updated in the parent table. A row in the child table is SET NULL when rows in the parent table are deleted/updated. |
Foreign Keys (Oracle) - Column Mapping
Under Referenced Table, choose the Owner and then the Name of the referenced, or parent, table.
Under the Main Table, select check boxes corresponding to the columns that are to reference columns in the referenced table. Then, under Referenced Table, select the corresponding column check boxes.