Relationships are critical to the design of an app's information model. Getting the relationships right as early as possible reduces expensive rework later in the process.
Relationship Types
There are four types of relationships in Apex Designer:
- Has many is the relationship that you probably think of first. An example is "a supplier has many locations".
- Belongs to is the opposite of has many. An example is "a location belongs to a supplier".
- Has one is a special case of has many. An example is "a supplier has one legal address".
- References is very similar to belongs to but communicates a different behavior. An example is "a supplier references an industry category". If the industry category was deleted, you would not expect the supplier to be deleted. Conversely, if a supplier was deleted, you would expect its locations to be deleted because "a location belongs to a supplier".
Creating Relationships
Relationships are in the top center section the Business Object page. You can add a relationship and create a business object at the same time (be sure to enter the singular (location) instead of the plural (locations) when creating a relationship and a business object):
You can also create a relationship with an existing business object:
Business Object Relationship Dialog
When you create a new relationship or click on an existing one, the Business Object Relationship dialog is displayed:
There are two rows displayed - one each each direction. You read them as sentences from right to left:
- a Location has many contacts of type Contact
- a Contact belongs to a location of type Location
You can click on the business object name to open it.
You can change the relationship type (from has many to has one for example) and the relationship name (contacts to supportContacts for example).
The Delete Behavior field has four options:
You can delete the relationship by clicking the Delete icon button at the bottom of the dialog.
Multiple Relationships with One Business Object
Consider this example:
- a supplier has one mailing address
- a supplier has one legal address
That is actually two distinct relationships between supplier and address. The relationships look like this:
The belongs to relationship names are verbose but they won't be misunderstood :).
What About Many To Many Relationships?
What about the example "a student has many classes and a class has many students"? Many to many relationships are represented by adding a linking business object. It could be called "Enrollment" and it would belong to both Student and Class:
Business Objects Diagram
Don't forget that you can visualize your business object relationships in a diagram form (see Business Objects Diagram for details):