Constraints

Constraints in NPCL specify the relationships that are allowed between instances of the types defined by the schema. NPCL has three kinds of constraints:

Occurrence Constraints

Occurrence Constraints are allowed only on Topic Types. These constraints specify the types of occurrences that are allowed on a topic of a specific Topic Type.

Role Player Constraints

Role Player Constraints are allowed only on Topic Types. They specify the types of roles in associations that can be played by a topic of a specific Topic Type.

Association Role Constraints

Association Role Constraints occur only on Association Types. They specify the types of roles that can be present in an association of a specific Association Type.

All of the constraints support the Minimum Cardinality and Maximum Cardinality facets which specify a numeric limit on the number of relationships (e.g. the number of occurrences of type "Age" that can appear on a topic of type "Person" could be limited to a minimum of 0 and a maximum of 1). Some constraints provide additional rules about how topics can be related to each other. The following sections describe each constraint in more detail.

Occurrence Constraints

An Occurrence Constraint specifies that a topic of a specific Topic Type can have occurrences of a specific Occurrence Type. The Minimum Cardinality and Maximum Cardinality facets specify how many occurrences of the Occurrence Type are allowed on any single instance of the Topic Type.

Role Player Constraints

A Role Player Constraint specifies that a topic of a specific Topic Type can play a role of a specific Role Type. These constraints can also optionally limit the roles played to only those in an association of a specific Association Type.

The Minimum and Maximum Cardinality facets constrain how many roles of the specified Role Type any instance of the specified Topic Type may participate in.

Association Role Constraints

An Association Role Constraint specifies that an association of a specific Association Type can have a role of a specific Role Type.

The Minimum and Maximum Cardinality facets constraint how many roles of the specified Role Type can appear on any single instance of the specified Association Type.

Note

At this point it might seem confusing that there are limits on how many roles a topic can play and how many roles can appear in an association. However, the two controls apply in different circumstances. Consider a topic map in which we want to record people and the companies they work for. We want to record each Person-to-Company relationship as a separate association, but we recognise that a Company will have many employees and a Person may work for more than one company. We create topic types "Person" and "Company", association type "Employment" and Role Types "Employee" and "Employer". In this example, we would allow the Person Topic Type to play 0 or more roles of type "Employee" and the "Company" topic type to play 0 or more roles of type "Employer", using the Cardinality facets on the Role Player Constraints. However, to ensure that we keep each Person-Company relationship in a separate associaction, we would restrict the "Employment" Association Type to have exactly one role of type "Employer" and exactly one role of type "Employee" (set Minimum and Maximum Cardinality to "1").

The Association Role Constraint also supports an additional Arc Label Facet. This facet specifies a default human-readable label for the role. This label should be the way to describe the association relationship when seen from the point of view of the role player. For example an association describing the relationship between a person and the company they work for might be represented using the Association Type "Employment", with Role Types "Employee" and "Employer". This implies that there are two Association Role Constraints, one between the Association Type "Employment" and the Role Type "Employee" and the other between the Association Type "Employment" and the Role Type "Employer". For the "Employee" Role Type, a suitable arc label might be "Works For" whereas for the "Employer" Role Type we might use "Employs".