Foreign keys
Use the Cúram generator to create foreign keys between database tables.
A foreign key relationship between two database tables is specified in the input
model by adding a relationship of stereotype foreignkey (one word, no spaces)
between two entity classes. Optionally, you can name the relationship. The relationship name is then
applied to the foreign key constraint added to the database. Otherwise, the database chooses its own
name for the constraint.
The following rules apply to using foreign keys:
- Foreign key relationships are allowed on entity classes only.
- Fields that are referenced by a foreign key are set to unique, as the unique field is required by some databases.
- If the foreign key references the primary key of another entity, the generator does not produce a redundant unique clause as the primary key is already unique.
- Foreign keys cannot be specified on subclass entities. You must specify the relationship by using the actual base entity classes themselves.