FK and Draft FK
From Conceptual to Logical
A foreign key is a set of attributes in a table that refers to the primary key (or unique constraint) of another table, linking these two tables.
In conceptual and logical level, foreign keys are defined from the entity. Each attributes has an FK fields. When selected, it indicates the attribute should be part of a foreign key constraint at a physical level.
In this case we understand that team_id and country_id are referencing to other entities. Supposedly a Team entity and a Country entity.
In this case, both my entities have attributes marked as FK. We can suppose that drivers.team_id refers to teams.team_id. But the model does not include the other entities that would be referred by the other FK attributes (teams.power_unit_supplier_id, teams.country_id and drivers.country_id). Supposedly a power_unit_suppliers entity and a countries entity.
From Physical
Physical level brings a more advanced support of foreign key constraints. When converted FK attributes are converted to Draft FK attributes.
In physical level, foreign keys are defined from the relationships. Each relationships must link a set of source attributes (PK or Unique) to a set of target attributes (FK).
If a relationships doesn’t link 2 sets of attributes, it is considered a draft relationship and will be highlighted in red.
To define the linked attributes from the relationships, use the foreign key constraint editor.
From the editor, you can see the Draft FK attributes as suggestions for target attributes.
Source attributes must be the the PK or a Unique constraint.
How to open the foreign key constraint editor?
The foreign key constraint editor can be opened from the relationship context menu or the relationship editor.
Adding physical Draft FK to the entity page
By default, Draft FKs are only used when converting a model to physical level. In addition, the Draft FK field is not visible from the entity page. But it is possible to enable the field to let users define Draft FK from the entity.
As an admin, in the Metadata Settings, you can enable the Draft FK for the entity page.
Summary
Defining foreign key | Conceptual | Logical | Physical |
|---|---|---|---|
From the entity | FK | FK | Draft FK (hidden by default) |
From the relationship | Hidden by default | Hidden by default | FK |