Foreign keys (join columns)
![Portions of two database tables are shown graphically as collections of rectangular cells like a table or a matrix. Some of the columns are labeled with the names of the represented column in the database table. For the table named "customer", only the customer_num column is labeled. The customer_num column is shaded and marked as the primary key of the table. For the table named "orders" two columns are labeled: order_num, and customer_num. The customer_num column is shaded and marked as the foreign key. A gray arrow points from one of the cells in the customer_num column of the orders table to one of the cells in the customer_num column in the customer table. This shows that the value in foreign key column refers to an existing value in the primary key column.](ddi015.gif)
Foreign keys are noted wherever they appear in the model because their presence can restrict your ability to delete rows from tables. Before you can delete a row safely, either you must delete all rows that refer to it through foreign keys, or you must define the relationship with special syntax that allows you to delete rows from primary-key and foreign-key columns with a single delete command. The database server does not allow deletions that violate referential integrity.
To preserve referential integrity, delete all foreign-key rows before you delete the primary key to which they refer. If you impose referential constraints on your database, the database server does not permit you to delete primary keys with matching foreign keys. It also does not permit you to add a foreign-key value that does not reference an existing primary-key value. For more information about referential integrity, see the HCL OneDB™ Guide to SQL: Tutorial.