# 1

# Declared foreign keys

All the foreign key constraints (where the contents of one or more columns in a table is constrained to be among the values of one or more columns of another table) are analysed and reported in the Schema Browser perspective. Foreign key constraints help understand the database schema and is automatically used where appropriate by the application.

However sometimes the designer of a database has forgotten or did not whish to use foreign key constraints, and so it is possible to "declare foreign keys" which are only declaration to the tool and not actually defined in the database.

# Declared foreign keys in diagrams

When displayed in diagrams, declared foreign keys are represented using a dashed line instead of a solid line for actual foreign keys

Σημειώσεις:

the (foreign key name, table, referenced table) triplet uniquely identifies a declared foreign key and thus declaring a new foreign key with the same triplet will remove any previously declared one.

If the same constraint is actually represented by a real foreign key and also by a declared foreign key, then the real foreign key definition will mask the declared one

Declared foreign key don't have any policy to determine what action to perform on UPDATE or DELETE situations, so the reported policy will always be "not enforced"

# Declaring a new foreign key

A new foreign key can be declared from the Schema Browser perspective using the Table Declare foreign key menu which is present when a table's properties are shown in the current tab.

Another way of declaring a foreign key is using the contextual menu on a table in a diagram, and selecting the Declare foreign key for this table option.

In any way, to declare a new foreign key, the following information must be provided:

A foreign key name

The referenced table

Columns and referenced columns for each column involved in the foreign key

## Information to declare a new foreign key

UI dialog poping up to declare a new foreign key. Here the referenced table is 'warehouses', and the involved columns are 'country' and 'city'.

# Remove a declared foreign key

A declared foreign key can be removed by clicking on the (Remove) link displayed below each declared foreign key properties in the table's properties (in the Schema Browser perspective).

Another way to remove a declared foreign key is in a diagram page through the contextual menu associated with the dashed line representing the declared foreign key, selecting the Remove this declared foreign key option.