Foreign keys

A foreign key is a key used to link two tables together.

When the primary key of one table (parent) is added to another table (child), this becomes the child table's foreign key.

Foreign keys are used in SqlDBM to link tables visually on a diagram.

Adding foreign keys

To add a foreign key to a (child) table, first, make sure that it exists as a primary key in another (parent) table. (See article on adding primary key constraints to tables).

Click on the parent table and drag the bottom-right knob to the child table.

By default, the foreign keys will be added to as primary keys in the child table. However, this can be changed by dragging the foreign key fields to the bottom part of the child table to make them non-primary.

Figure 1. adding a foreign key relationship

See also:

Primary keys

Did this answer your question?