Choose your database:
AnySQL
MySQL
MS SQL Server
PostgreSQL
SQLite
Firebird
Oracle
SQL Anywhere
DB2
MaxDB

Subscribe to our news:
Partners
Testimonials
Stephen Arrowel, Database Administrator: "We are in the process of implementing Firebird solutions at multiple levels in our international organization. We expect that SQL Maestro Group will do nothing short of revolutionize the way we develop and maintain our Firebird databases. The continuous improvement and development means that the product is extremely flexible and will grow with us. The service and responsiveness of the Support Team has been exceptional. They have devoted countless hours to understanding our needs, so that we could get a Firebird administration tool which would be so simple and effective in use. SQL Maestro Group is helping Sytrax sail into the 21st Century".
Carl Schammel: "I have been in search of a software product that was rich in features and easy for using, but was unable to find one until I came upon Firebird Maestro. Not only does it have all-inclusive integrated functionality, but SQL Maestro Group have provided me with superior support. I now have the management tools at my hand that I have been looking for".

More

Add your opinion

Firebird Maestro online Help

Prev Return to chapter overview Next

Foreign Keys

A foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table. In other words, a foreign key is a column or a combination of columns that is used to establish and enforce a link between the data in two tables.
 

Note: To create a foreign key constraint, it is necessary to have this privilege for both the referencing and referenced tables.

 

 

Foreign keys are created within the Foreign Key Properties dialog window. In order to open the dialog you should either

 

open the table in Table Editor and the Foreign Keys tab there;
press the Insert key or select the Add New Foreign Key... item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar)

or

select the table in the explorer tree and use the Create New Foreign Key popup menu item

or

select the table Foreign Keys node or any foreign key within the table in the explorer tree and use the Add New Foreign Key... popup menu item.

 

 

 

Foreign Keys are edited within the Foreign Key Properties dialog window. In order to open the dialog you should either

 

open the table in Table Editor and the Foreign Keys tab there;
press the Enter key or select the Edit Foreign Key item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar)

or

select the foreign key to edit in the explorer tree and use the Edit Foreign Key popup menu item.

       

You can change the name of the foreign key using the Rename Foreign Key dialog. To open the dialog you should either

 

select the foreign key to rename in the explorer tree;
select the Rename Foreign Key item from the popup menu

or

open the table in Table Editor and the Foreign Keys tab there;
select the foreign key to rename;
select the Rename Foreign Key item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar).

 

 

 

To drop the foreign key:

 

select the foreign key to drop in the explorer tree;
select the Drop Foreign Key item from the popup menu

or

open the table in Table Editor and the Foreign Keys tab there;
press the Delete key or select the Drop Foreign Key item from the popup menu (alternatively, you may use the corresponding link of the Navigation Bar)

 

and confirm dropping in the dialog window.

 

 

Set the Foreign Key Name, select Columns from the Available Fields list to include into the foreign key, select the Foreign Table Name from the drop-down list and its fields from the list to include, set other foreign key properties and apply the changes by clicking the OK button.

 

 

All the fields which are included into the Foreign Key must be included into indexes as well. See Indexes for details.

 

 

Set rules ON DELETE and ON UPDATE from the respective drop-down lists.

 

NO ACTION Produce an error indicating that the deletion or update will create a foreign key constraint violation. If the constraint is deferred this error will be produced at constraint check time if there still exist any referencing rows. This is the default action.

 

CASCADE Delete any rows referencing the deleted row, or update the value of the referencing column to the new value of the referenced column, respectively.

 

SET NULL Set the referencing column(s) to null.

 

SET DEFAULT Set the referencing column(s) to their default values.

 

Index name

Specify the index name for the foreign key.

 

Index sorting

Ascending. Sorts columns in ascending order, the default order if none is specified.

Descending. Sorts columns in descending order.



Prev Return to chapter overview Next