Ensure a Decision Can Be Made
When your policy model uses entities, it is important to ensure that at runtime the entities will be able to be complete. Where an entity is not complete, there is a risk that attributes proved by rules using the entity will remain unknown. This is particularly the case with rules that rely on quantification over sets of entities.
An entity is complete when the rule engine has values for the entire set of instances for that entity.
Whether or not an entity is complete is of major importance when determining whether or not a relationship is partially known. See Get Answers Even When Relationships Are Only Partially Known for more information.
The completion status of an entity is determined by the engine using containment relationships. A containment relationship is a one-to-many relationship from a parent entity to a child entity, and is created automatically when an entity instance is added. An entity Y is considered to be complete if:
- A one-to-many containment relationship is defined from some other entity X to entity Y. We say that Y is contained by X, and we refer to the relationship as entity Y's containment relationship.
- Entity Y's containment relationship is set (that is, it is known) for all instances of entity X.
- Entity X is also considered to be complete.
Note that the global entity is always automatically complete. It is not necessary (or possible) to create a containment relationship for the global entity.
Consider the example provided in the following diagram:
In this scenario:
- The global entity is automatically complete.
- Entity X is complete. This is because its containment relationship from the global is known.
- Entity Y is complete. This is because its containment relationship is known for all instances of entity X, and entity X is complete.
Consider this second scenario:
In this scenario:
- The global entity is automatically complete.
- Entity X is complete. This is because its containment relationship from the global is known.
- Entity Y is not complete, because its containment relationship is not known for all instances of entity X.
Consider this third scenario:
In this scenario:
- The global entity is automatically complete.
- Entity X is not complete, as its containment relationship is not known.
- Entity Y is not complete, as entity X is not complete. This is the case even though entity Y's containment relationship is known for all instances of entity X.
-
When no instances meet the query, zero instances are loaded and the relationship is marked as complete.
- The containment relationship for a query mapped entity is unknown if any attribute/entity/relationship used in the query is unknown, even if entity instances are loaded.
- If all attributes/entities/relationships used in a query are known but one or more of them is uncertain, the containment relationship is uncertain.
- For more information, see Define Conditions for Loading Data During an Interview.