Define Relationships Between Modeled Entities
Each modeled entity can have zero or more relationships with other modeled entities. These are used to enforce data integrity when creating and deleting data.
Uniface supports one-to-many relationships between entities. If an entity is used as a Many entity, it must have a field that holds the foreign key of the One entity.
Note: Relationships are defined in the Many entity rather than the One entity. This makes it easier to define the fields and keys used in the relationship.
To define a relationship between two entities:
- Open the Many entity of the relationship for
editing, and go to the Define Relationships worksheet.
The Relationship Editor displays a box representing the entity in the Many Entities column.
- In the Resource
Browser, find and select the One entity you want to add, then drag and drop it onto the Many
entity.
Tip: To find the One entity, you can start typing a name or keyword in the U-Bar of the Resource Browsers to get suggestions for entities that match the string in the object name or description.
The entity is added to the One column, with the Relationship in the middle. The Many Entity now shows an Illegal Property Value for the foreign key field.
- Click the drop-down arrow for the foreign
key field in Many entity, and select the field to use as the foreign key.
This maps the primary key of the One entity to the foreign key field in the Many entity.
- If necessary, change the properties of the
relationship. For example, you may need to specify the Delete
Constraint.
Click the line representing the relationship to select it, then set its properties in the Properties Inspector.