Memra

Constraints: Completeness & Disjointness

◈ 6 cards

The two constraint axes on every specialization — total vs partial (double vs single line) and disjoint d vs overlap o — their four combinations, and the discriminator each implies.

Two independent questions about every specialization

Once you have a supertype with subtypes, two business rules must be pinned down. They are independent — every specialization answers both — and they are the single most heavily tested notation in Chapter 3.

### 1. Completeness — must a supertype instance be in some subtype?

A completeness constraint addresses whether an instance of the supertype must also be a member of at least one subtype.

  • Total specialization rule: every supertype instance must belong to some subtype. There are no "uncategorized" instances. Drawn as a double line from the supertype to the circle. (Insert a new supertype instance → you must simultaneously place it in at least one subtype.)
  • Partial specialization rule: a supertype instance is allowed not to belong to any subtype. Drawn as a single line. (The MOTORCYCLE-under-VEHICLE case: a valid VEHICLE in no subtype.) Partial is actually the more common case in practice — most real classifications have exceptions.

### 2. Disjointness — may an instance be in two subtypes at once?

A disjointness constraint addresses whether an instance of the supertype may simultaneously be a member of two or more subtypes.

  • Disjoint rule: if an instance is in one subtype, it cannot be in any other at the same time — mutually exclusive. Marked by the letter d in the circle. (An instance may change subtype over time — a UNION employee promoted to MANAGEMENT — but at any one moment it is in only one.)
  • Overlap rule: an instance may be in two or more subtypes simultaneously. Marked by the letter o in the circle. (Part #4000 has both manufactured and purchased units on hand, so it is both a MANUFACTURED_PART and a PURCHASED_PART at once.)

The subtype discriminator

A subtype discriminator is an attribute of the supertype whose value determines which subtype(s) an instance belongs to. Its form follows directly from the disjointness rule:

  • Disjoint → a simple attribute with mutually exclusive values: Employee_Type = 'H' (hourly) | 'S' (salaried) | 'C' (consultant). One value → one subtype.
  • Overlap → a composite attribute of Boolean components, one per subtype: Part_Type with Manufactured? = Y/N and Purchased? = Y/N. An instance can be Y on more than one, so it can sit in more than one subtype.

A disjoint discriminator can't represent dual membership (one value, one subtype), which is why overlap demands the composite-Boolean form.

The four combinations (memorize this table)

Because the two axes are independent, every specialization is one of four combinations:

CombinationMeaningTextbook example
total / disjointevery instance is in exactly one subtypePATIENT → OUTPATIENT \
total / overlapevery instance is in at least one, possibly severalPART → MANUFACTURED \
partial / disjointan instance is in at most one subtype, or noneEMPLOYEE → MANAGEMENT \
partial / overlapan instance is in zero, one, or many subtypesPERSON → EMPLOYEE \

Worked example — choosing both constraints

An organization has employee types full-time salaried, part-time hourly, and contract. Every employee is at least one of these, and some contract workers are also part-time hourly. Specify the constraints.

  • Completeness: every employee must be at least one type → total (double line).
  • Disjointness: a contract worker can simultaneously be part-time hourly → overlap (o).
  • Discriminator: overlap ⇒ a composite Boolean discriminator on EMPLOYEE: Full_Time_Salaried? (Y/N), Part_Time_Hourly? (Y/N), Contract? (Y/N). A contract/part-time worker is Y on two components.

So this is a total/overlap specialization. Walking the two axes independently — must they be in one? then may they be in several? — and then reading the discriminator off the disjointness answer is the whole exam procedure.

total /overlap(o)total /overlap(o)total /overlap(o)EMPLOYEEEmployee_NumberFull_Time_Salaried?Y/NPart_Time_Hourly?Y/NContract?Y/NFULL_TIME_SALARIEDPART_TIME_HOURLYCONTRACT
Total/overlap specialization — every employee is at least one type, and some are two at once.
NORMAL ~/memra/learn/comp-378/completeness-disjointness-constraints utf-8 LF