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.
Understand the different types of relationships
Create a relationship in a properties file
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
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
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.
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
An inferred relationship is a many-to-many relationship that can have its membership concluded by rules in the rulebase.
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.
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.
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 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.
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.
Containment relationships are defined when the associated entities are first created in the rulebase.
To create a reference relationship between two entities in a properties file: