## Specifying constraints in Spertype / Subtype Relationships

Constraints allow us to capture some of the important business rules that apply to these relationships. The two most important constraints are completeness constraint and disjointness constraint.

1. completeness constraint

A completeness constraint address the question whether an instance of a supertype must also be a member of at least one subtype. The completeness constraint has two possible rules.

a) Total specialization

The total specialization rule specifies that each entity instance of the supertype must be a member of some subtype in the relationship.

In the above example, the business rule is a patient must be either an out patient or resident patient. The double line extending from the patient entity type to the circle indicates total specialization.

b) Partial specialization

The partial specialization  rule specifies that an entity instance of supertype is not belong to any subtype.

A vehicle is a car, it must appear as an instance of CAR, and if it is a truck, it must appear as an instance of TRUCK. However, if the vehicle is a motorcycle, it cannot appear as an instance of any subtype. This is an example of partial specialization, and it is specified by the single line from the VEHICLE supertype to the circle.

2. Disjointness constraints

A constraint that addresses whether an instance of a supertype may simultaneously be a member of two (or more) subtypes. It has two possible rules

a) Disjoint rule

A rule that specifies that an instance of a supertype may not simultaneously be a member of two (or more) subtypes.

In the above example, the business rule is a patient must be either an out patient or resident patient but cannot both. The disjoint rule is specified by the letter 'd' in the circle joining the supertype.

b) Overlap rule

A rule that specifies that an instance of a supertype may simultaneously be a member of two (or more) subtypes.

In the above example, part can be simultaneously be a member of manufactured parts and purchased parts. In this example, part part has a particular number. The overlap rule is specified by placing the letter 'o' in the circle joining the supertype and its subtype.

More

More

More

More

More

More
Top