Example: Compare One Instance to All Other Instances of the Same Entity
Reasoning can also be conducted from one instance of an entity to another instance of the same entity. For example, to determine:
- whether children are living in the same household
- who should be considered the primary applicant or contact
- which product is most desirable
Comparing one instance to all other instances of the same entity can be achieved by traversing from the entity-level conclusion up to the Global level (Level 1 condition) and then back down to all entity instances (Level 2 condition). For example, assume you have a policy model with the entity "the person" where the containment relationship is "all instances of the person".
You could use the following rule to examine instances of the person entity to see whether a person’s identification code is used by multiple people:
the person has a conflicting identification code if
ExistsScope(all instances of the person, the colleague)
the person's identification code = the colleague’s identification code and
the person is not the colleague
Notice that an alias ("the colleague") has been used to distinguish between the person instance referred to in the conclusion line and all other instances of the person entity.
Using this technique, the identification code for each employee entity instance is compared against all employee identification codes, one of which will be a match between the same entity instance. To eliminate this match from the concluded outcome of the rule, the last line of the rule uses the plain language version of the InstanceEquals function to ensure only identification code matches from different entity instances cause the rule to evaluate to true.
Tip: To see the rules in this example in action, open the Worked Example 3 project in Oracle Policy Modeling.