Supertypes and Subtypes Entities:
Definition and Explanation:
An entity can be divided into several subtypes. An entity type that can be
subdivided into subtypes is called supertype. A subtype is a subset of a supertype that shares common attributes. Subtypes behave in exactly the same way
as any entity type. For example, entity subtypes have attributes and may have
relationships with other entity types.
Suppose EMPLOYEE and PROGRAMMER are two entity types. If some employees are
programmers, and all programmers are employees, then we can say that PROGRAMMER
is a subtype of the EMPLOYEE. All properties of EMPLOYEE entity apply
automatically to PROGRAMMER entity but the reverse is not true.
An entity subtype can further be subdivided and can have subtypes of its own.
For example, programmers may be subdivided into application programmers and
system programmers. Thus we can say that application programmer and system
programmer are subtypes of programmer (supertype) and so on. Thus an entity may
constitute a type hierarchy as shows in figure below.
Diagram:

IS-A Relationship:
The relationship between each subtype and supertype is called IS-A or IS-AN
relationship. For example, we say that "Programmer IS-AN Employee". Similarly,
we say that ""A" IS-A Student". A rectangle with rounded edges is used to
designate IS-A relationship (or simply ISA relationship). The relationship is
read from the subtype to the supertype. The primary key for supertype is
included with each of the subtype.
The cardinality of the relationship from a subtype to the supertype is mandatory
one; it is because an instance of a subtype is always an instance of the
supertype. On the other hand, the cardinality of the relationship from the
supertype to the subtype is optional zero or one. In the figure below, the
symbol of curved line is also shown just below the supertype. It indicates the
exclusive relationship. In exclusive relationship, subtype and supertype are
mutually exclusive, and each instance of the supertype is required to be a
member of exactly one subtype. For example, each employee must be a programmer,
a clerk, or a manager.

In the figure above, the common attributes for all employees are included with
the EMPLOYEE entity type. The primary key for EMPLOYEE as well as for each of
the subtypes is 'Emp-ID'.
Inheritance is another important concept associated with subtypes and
supertypes. It is the property by which all attributes (and relationships) of a
supertype become attributes of its subtypes.
In the figure above, the attributes Name and Address of EMPLOYEE are inherited
by PROGRAMMER. These attributes are not attached to the subtype such as
PROGRAMMER.
|