Define a relationship

Relationships define how entities relate to one another. All entities must have a containment relationship defined, which specifies the overall structure of the rulebase. In addition, reference relationships can be defined between entities if appropriate for your data model. You need to have already defined your entities before you can add reference relationships.

By specifying a relationship you are specifying whether an instance of an entity is related to one or more of the instances of another (or even the same) entity group.

For example, if you have:

Then there is a single relationship, but there are three relationship instances, because each person has a list of the cars that belong to them.

That is, Tom has a VW and Mazda, Dick has a Ford, and Harry has a Holden and Ford.

What do you want to do?

Understand the different types of relationships

Create a relationship in a properties file

Understand the different types of relationships

One-to-One

A one-to-one relationship is where one entity instance interacts only with one other entity instance.

 

Entity 1: the nut

Entity 2: the bolt

Relationship from the nut to the bolt: the nut's bolt

One-to-Many

A one-to-many relationship is where one entity instance interacts with many other entity instances. This is the traditional hierarchical model relationship.

 

Entity 1: the owner

Entity 2: the pet

Relationship from the owner to the pet: the owner's pets

Many-to-Many

A many-to-many relationship is where multiple instances can interact with many other entity instances. In the example below, the Pets "Bella" and "Lochie" share the Owners "Ping" and "Euan", whilst Chip has only one owner Euan.

 

Entity 1: the pet

Entity 2: the owner

Relationship from the pet to the owner: the pet's owners

TIP: To see a simple example of a complete rulebase with a many-to-many relationship, open and run the Parents And Children example rulebase project provided in the Examples folder in the Oracle Policy Modeling installation folder.

Many-to-One

A many-to-one relationship is where many entity instance belong to only one entity instance. This is the reverse of a one-to-many relationship.

 

Entity 1: the pet

Entity 2: the owner

Relationship from the pet to the owner: the pet's owner

Inferred (Many-To-Many)

An inferred relationship is a many-to-many relationship that can have its membership concluded by rules in the rulebase.

Reverse Relationships

Reverse relationships occur where an entity has a relationship to another entity, and that entity has a relationship back again. For example, a parent has a child and a child has a parent.

However, not all relationships have a logic reverse and not all relationships require capturing the reverse relationship. For example, it might be useful to collect that an applicant has applied for multiple benefits but there is no need to identify all of the applicants for a particular benefit.

In determining whether or not to capture a reverse relationship, consider whether both directions of the relationship will be useful in your rules. If in doubt, create the reverse relationship - it won't be activated unless you have rules which refer to it.

Self-Referential Relationships

Sometimes it is necessary to relate one entity instance to another entity instance in the same entity. For example, a child in a family may have a special relationship with another child in the family, such as being twins or sharing a room.

This type of a relationship is treated the same as other entity types, except that both the source and the target of the relationship are the same entity.

Containment Relationships

All entities must have a containment relationship defined. The collection of containment relationships that link entities in the rulebase together allows us to see the logical structure of the data model. For example, a rulebase may have two entities 'the guardian' and 'the child', with two containment relationships defined: a one-to-many relationship "the guardians" from the global entity to the guardian entity, and a one-to-many relationship "the guardian's children" from the guardian entity to the child entity. The containment relationship for an entity must be either many-to-one or one-to-one, ie each entity instance must be contained by a single parent entity instance. Additional relationships (reference relationships) between entities can be defined as needed for your rulebase data model. See Understand containment relationships and entity completion for more information.

Reference Relationships

Reference relationships define meaningful connections between entities that exist in addition to the entities' containment relationships. For example, an entity 'the person' may have a containment relationship from the global entity called "the people", and an additional reference relationship to capture groups of people who live together called "the person's housemate", which is a self-referential relationship between instances of the person entity.

Create a relationship in a properties file

Relationships are declared in a properties file for the project, rather than in individual Word and Excel documents. This eliminates the need to re-declare the same relationships in each rule file.

Create a containment relationship

Containment relationships are defined when the associated entities are first created in the rulebase.

Create a reference relationship

To create a reference relationship between two entities in a properties file:

  1. In Oracle Policy Modeling, double click your properties file to open it. In the Entity Explorer, select the entity that you want to create a relationship for. (The containment relationships already defined for the entity will be shown in the relationships window.)



  2. In the relationships window, right-click and select New Relationship...



  3. In the Relationship Editor dialog box, select the Browse button next to the Target field to select the target entity.



  4. In the Entity Selector dialog box select the target entity then click OK.



  5. In the Relationship Editor dialog select the type of relationship from the drop-down menu.



  6. Enter the textual form of the relationship name in the Text field. Relationships should be given a meaningful name, usually using the definite article 'the' (for example, 'the children', 'the child's school' etc). For more information, see Choose a name for a relationship.



  7. Enter the textual form of the reverse relationship in the Reverse text field. If a reverse relationship is not specified then by default it is not possible to traverse the relationship backwards.



  8. Click OK. Repeat this process for any additional relationships you want to add. The relationships that you have added will now be displayed in the Relationships window.