Beruflich Dokumente
Kultur Dokumente
The ER modeling concepts discussed in Chapter 3 are sufficient for representing many database
schemas for traditional database applications, which include many data-processing applications
in business and industry. Since the late 1970s, however, designers of database applications
have tried to design more accurate database schemas that reflect the data properties and
constraints more precisely. This was particularly important for newer applications of database
technology, such as databases for engineering design and manufacturing (CAD/CAM),1
telecommunications, complex software systems, and geographic information systems (GISs),
among many other applications. These types of databases have requirements that are more
complex than the more traditional applications. This led to the development of additional
semantic data modeling concepts that were incorporated into conceptual data models such as
the ER model. Various semantic data models have been proposed in the literature. Many of
these concepts were also developed independently in related areas of computer science, such
as the knowledge representation area of artificial intelligence and the object modeling area in
software engineering.
In this chapter, we describe features that have been proposed for semantic data models and
show how the ER model can be enhanced to include these concepts, which leads to the
enhanced ER (EER) model.2 We start in Section 4.1 by incorporating the concepts of
class/subclass relationships and type inheritance into the ER model. Then, in Section 4.2, we
add the concepts of specialization and generalization. Section 4.3 discusses the various types
of constraints on specialization/generalization, and Section 4.4 shows how the UNION
construct can be modeled by including the concept of category in the EER model. Section 4.5
gives a sample UNIVERSITY database schema in the EER model and summarizes the EER
model concepts by giving formal definitions. We will use the terms object and entity
interchangeably in this chapter, because many of these concepts are commonly used in
objectoriented models.
We present the UML class diagram notation for representing specialization and generalization
in Section 4.6, and we briefly compare these with EER notation and concepts. This serves as
an example of alternative notation, and is a continuation of Section 3.8, which presented basic
UML class diagram notation that corresponds to the basic ER model. In Section 4.7, we discuss
the fundamental abstractions that are used as the basis of many semantic data models. Section
4.8 summarizes the chapter.
For a detailed introduction to conceptual modeling, Chapter 4 should be considered a
continuation of Chapter 3. However, if only a basic introduction to ER modeling is desired,
this chapter may be omitted. Alternatively, the reader may choose to skip some or all of the
later sections of this chapter (Sections 4.4 through 4.8).
The EER model includes all the modeling concepts of the ER model that were presented in
Chapter 3. In addition, it includes the concepts of subclass and superclass and the related
concepts of specialization and generalization (see Sections 4.2 and 4.3). Another concept
included in the EER model is that of a category or union type (see Section 4.4), which is used
to represent a collection of objects (entities) that is the union of objects of different entity types.
Associated with these concepts is the important mechanism of attribute and relationship
inheritance. Unfortunately, no standard terminology exists for these concepts, so we use the
most common terminology. Alternative terminology is given in footnotes. We also describe a
diagrammatic technique for displaying these concepts when they arise in an EER schema. We
call the resulting schema diagrams enhanced ER or EER diagrams.
The first enhanced ER (EER) model concept we take up is that of a subtype or subclass of an
entity type. As we discussed in Chapter 3, the name of an entity type is used to represent both
a type of entity and the entity set or collection of entities of that type that exist in the database.
For example, the entity type employee describes the type (that is, the attributes and
relationships) of each employee entity, and also refers to the current set of employee entities in
the company database. In many cases an entity type has numerous subgroupings or subtypes
of its entities that are meaningful and need to be represented explicitly because of their
significance to the database application. For example, the entities that are members of the
employee entity type may be distinguished further into secretary, engineer, manager,
technician, salaried_employee, hourly_employee, and so on. The set or collection of entities in
each of the latter groupings is a subset of the entities that belong to the employee entity set,
meaning that every entity that is a member of one of these subgroupings is also an employee.
We call each of these subgroupings a subclass or subtype of the employee entity type, and the
employee entity type is called the superclass or supertype for each of these subclasses. Figure
4.1 shows how to represent these concepts diagramatically in EER diagrams. (The circle
notation in Figure 4.1 will be explained in Section 4.2.)
We call the relationship between a superclass and any one of its subclasses a
superclass/subclass or supertype/subtype or simply class/subclass relationship.3 In our
previous example, employee/secretary and employee/technician are two class/subclass
relationships. Notice that a member entity of the subclass represents the same real-world entity
as some member of the superclass; for example, a secretary entity ‘Joan Logano’ is also the
employee ‘Joan Logano.’ Hence, the subclass member is the same as the entity in the
superclass, but in a distinct specific role. When we implement a superclass/subclass
relationship in the database system, however, we may represent a member of the subclass as a
distinct database object—say, a distinct record that is related via the key attribute to its
superclass entity. In Section 9.2, we discuss various options for representing
superclass/subclass relationships in relational databases.
An entity cannot exist in the database merely by being a member of a subclass; it must also be
a member of the superclass. Such an entity can be included optionally as a member of any
number of subclasses. For example, a salaried employee who is also an engineer belongs to the
two subclasses engineer and salaried_employee of the employee entity type. However, it is not
necessary that every entity in a superclass is a member of some subclass.
An important concept associated with subclasses (subtypes) is that of type inheritance. Recall
that the type of an entity is defined by the attributes it possesses and the relationship types in
which it participates. Because an entity in the subclass represents the same real-world entity
from the superclass, it should possess values for its specific attributes as well as values of its
attributes as a member of the superclass. We say that an entity that is a member of a subclass
inherits all the attributes of the entity as a member of the superclass. The entity also inherits all
the relationships in which the superclass participates. Notice that a subclass, with its own
specific (or local) attributes and relationships together with all the attributes and relationships
it inherits from the superclass, can be considered an entity type in its own right.
4.2.1 Specialization
Specialization is the process of defining a set of subclasses of an entity type; this entity type is
called the superclass of the specialization. The set of subclasses that forms a specialization is
defined on the basis of some distinguishing characteristic of the entities in the superclass. For
example, the set of subclasses {secretary, engineer, technician} is a specialization of the
superclass employee that distinguishes among employee entities based on the job type of each
employee. We may have several specializations of the same entity type based on different
distinguishing characteristics. For example, another specialization of the employee entity type
may yield the set of subclasses {salaried_employee, hourly_employee}; this specialization
distinguishes among employees based on the method of pay.
Figure 4.1 shows how we represent a specialization diagrammatically in an EER diagram. The
subclasses that define a specialization are attached by lines to a circle that represents the
specialization, which is connected in turn to the superclass. The subset symbol on each line
connecting a subclass to the circle indicates the direction of the superclass/subclass
relationship.5 Attributes that apply only to entities of a particular subclass—such as
TypingSpeed of secretary—are attached to the rectangle representing that subclass. These are
called specific (or local) attributes of the subclass. Similarly, a subclass can participate in
specific relationship types, such as the hourly_employee subclass participating in the
belongs_to relationship in Figure 4.1. We will explain the d symbol in the circles in Figure 4.1
and additional EER diagram notation shortly.
Figure 4.2 shows a few entity instances that belong to subclasses of the {secretary, engineer,
technician} specialization. Again, notice that an entity that belongs to a subclass represents the
same real-world entity as the entity connected to it in the EMPLOYEE superclass, even though
the same entity is shown twice; for example, e1 is shown in both employee and secretary in
Figure 4.2. As the figure suggests, a superclass/subclass relationship such as
employee/secretary somewhat resembles a 1:1 relationship at the instance level (see Figure
3.12). The main difference is that in a 1:1 relationship two distinct entities are related, whereas
in a superclass/subclass relationship the entity in the subclass is the same real-world entity as
the entity in the superclass but is playing a specialized role—for example, an employee
specialized in the role of secretary, or an employee specialized in the role of technician.
There are two main reasons for including class/subclass relationships and specializations. The
first is that certain attributes may apply to some but not all entities of the superclass entity type.
A subclass is defined in order to group the entities to which these attributes apply. The members
of the subclass may still share the majority of their attributes with the other members of the
superclass. For example, in Figure 4.1 the secretary subclass has the specific attribute
Typing_speed, whereas the engineer subclass has the specific attribute Eng_type, but secretary
and engineer share their other inherited attributes from the employee entity type.
The second reason for using subclasses is that some relationship types may be participated in
only by entities that are members of the subclass. For example, if only hourly_employees can
belong to a trade union, we can represent that fact by creating the subclass hourly_employee
of employee and relating the subclass to an entity type trade_union via the belongs_to
relationship type, as illustrated in Figure 4.1.
4.2.2 Generalization
We can think of a reverse process of abstraction in which we suppress the differences among
several entity types, identify their common features, and generalize them into a single
superclass of which the original entity types are special subclasses. For example, consider the
entity types car and truck shown in Figure 4.3(a). Because they have several common attributes,
they can be generalized into the entity type vehicle, as shown in Figure 4.3(b). Both car and
truck are now subclasses of the generalized superclass vehicle. We use the term generalization
to refer to the process of defining a generalized entity type from the given entity types.
Notice that the generalization process can be viewed as being functionally the inverse of the
specialization process; we can view {car, truck} as a specialization of vehicle rather than
viewing vehicle as a generalization of car and truck. A diagrammatic notation to distinguish
between generalization and specialization is used in some design methodologies. An arrow
pointing to the generalized superclass represents a generalization process, whereas arrows
pointing to the specialized subclasses represent a specialization process. We will not use this
notation because the decision as to which process was followed in a particular situation is often
subjective.
First, we discuss constraints that apply to a single specialization or a single generalization. For
brevity, our discussion refers only to specialization even though it applies to both specialization
and generalization. Then, we discuss differences between specialization/generalization lattices
(multiple inheritance) and hierarchies (single inheritance), and we elaborate on the differences
between the specialization and generalization processes during conceptual database schema
design.
In general, we may have several specializations defined on the same entity type (or superclass),
as shown in Figure 4.1. In such a case, entities may belong to subclasses in each of the
specializations. A specialization may also consist of a single subclass only, such as the
{manager} specialization in Figure 4.1; in such a case, we do not use the circle notation.
In some specializations we can determine exactly the entities that will become members of
each subclass by placing a condition on the value of some attribute of the superclass. Such
subclasses are called predicate-defined (or condition-defined) subclasses. For example, if the
employee entity type has an attribute Job_type, as shown in Figure 4.4, we can specify the
condition of membership in the secretary subclass by the condition (Job_type = ‘Secretary’),
which we call the defining predicate of the subclass. This condition is a constraint specifying
that exactly those entities of the employee entity type whose attribute value for Job_type is
‘Secretary’ belong to the subclass. We display a predicate-defined subclass by writing the
predicate condition next to the line that connects the subclass to the specialization circle.
If all subclasses in a specialization have their membership condition on the same attribute of
the superclass, the specialization itself is called an attribute-defined specialization, and the
attribute is called the defining attribute of the specialization.6 In this case, all the entities with
the same value for the attribute belong to the same subclass. We display an attribute-defined
specialization by placing the defining attribute name next to the arc from the circle to the
superclass, as shown in Figure 4.4.
When we do not have a condition for determining membership in a subclass, the subclass is
called user-defined. Membership in such a subclass is determined by the database users when
they apply the operation to add an entity to the subclass; hence, membership is specified
individually for each entity by the user, not by any condition that may be evaluated
automatically.
Two other constraints may apply to a specialization. The first is the disjointness constraint,
which specifies that the subclasses of the specialization must be disjoint sets. This means that
an entity can be a member of at most one of the subclasses of the specialization. A
specialization that is attribute-defined implies the disjointness constraint (if the attribute used
to define the membership predicate is single- valued). Figure 4.4 illustrates this case, where the
d in the circle stands for disjoint. The d notation also applies to user-defined subclasses of a
specialization that must be disjoint, as illustrated by the specialization {hourly_employee,
salaried_employee} in Figure 4.1. If the subclasses are not constrained to be disjoint, their sets
of entities may be overlapping; that is, the same (real-world) entity may be a member of more
than one subclass of the specialization. This case, which is the default, is displayed by placing
an o in the circle, as shown in Figure 4.5.
The second constraint on specialization is called the completeness (or totalness) constraint,
which may be total or partial. A total specialization constraint specifies that every entity in the
superclass must be a member of at least one subclass in the specialization. For example, if
every employee must be either an hourly_employee or a salaried_employee, then the
specialization {hourly_employee, salaried_employee} in figure 4.1 is a total specialization of
employee. This is shown in EER diagrams by using a double line to connect the superclass to
the circle. A single line is used to display a partial specialization, which allows an entity not to
belong to any of the subclasses. For example, if some employee entities do not belong to any
of the subclasses {secretary, engineer, technician} in Figures 4.1 and 4.4, then that
specialization is partial.
Notice that the disjointness and completeness constraints are independent. Hence, we have the
following four possible constraints on a specialization:
■ Disjoint, total
■ Disjoint, partial
■ Overlapping, total
■ Overlapping, partial
Of course, the correct constraint is determined from the real-world meaning that applies to each
specialization. In general, a superclass that was identified through the generalization process
usually is total, because the superclass is derived from the subclasses and hence contains only
the entities that are in the subclasses.
■ Inserting an entity in a superclass implies that the entity is mandatorily inserted in all
predicate-defined (or attribute-defined) subclasses for which the entity satisfies the defining
predicate.
The reader is encouraged to make a complete list of rules for insertions and deletions for the
various types of specializations.
A subclass itself may have further subclasses specified on it, forming a hierarchy or a lattice of
specializations. For example, in Figure 4.6 engineer is a subclass of employee and is also a
superclass of engineering_manager; this represents the real-world constraint that every
engineering manager is required to be an engineer. A specialization hierarchy has the constraint
that every subclass participates as a subclass in only one class/subclass relationship; that is,
each subclass has only one parent, which results in a tree structure or strict hierarchy. In
contrast, for a specialization lattice, a subclass can be a subclass in more than one
class/subclass relationship. Hence, Figure 4.6 is a lattice.
Figure 4.7 shows another specialization lattice of more than one level. This may be part of a
conceptual schema for a university database. Notice that this arrangement would have been a
hierarchy except for the student_assistant subclass, which is a subclass in two distinct
class/subclass relationships.
The requirements for the part of the UNIVERSITY database shown in Figure 4.7 are the
following:
1. The database keeps track of three types of persons: employees, alumni, and students. A
person can belong to one, two, or all three of these types. Each person has a name, SSN, sex,
address, and birth date.
2. Every employee has a salary, and there are three types of employees: faculty, staff, and
student assistants. Each employee belongs to exactly one of these types. For each alumnus, a
record of the degree or degrees that he or she earned at the university is kept, including the
name of the degree, the year granted, and the major department. Each student has a major
department.
3. Each faculty has a rank, whereas each staff member has a staff position. Student assistants
are classified further as either research assistants or teaching assistants, and the percent of time
that they work is recorded in the database. Research assistants have their research project
stored, whereas teaching assistants have the current course they work on.
4. Students are further classified as either graduate or undergraduate, with the specific
attributes degree program (M.S., Ph.D., M.B.A., and so on) for graduate students and class
(freshman, sophomore, and so on) for undergraduates.
In Figure 4.7, all person entities represented in the database are members of the person entity
type, which is specialized into the subclasses {employee, alumnus, student}. This
specialization is overlapping; for example, an alumnus may also be an employee and a student
pursuing an advanced degree. The subclass student is the superclass for the specialization
{graduate_student, undergraduate_student}, whereas employee is the superclass for the
specialization {student_assistant, faculty, staff}. Notice that student_assistant is also a subclass
of student. Finally, student_assistant is the superclass for the specialization into
{research_assistant, teaching_assistant}.
In such a specialization lattice or hierarchy, a subclass inherits the attributes not only of its
direct superclass, but also of all its predecessor superclasses all the way to the root of the
hierarchy or lattice if necessary. For example, an entity in graduate_student inherits all the
attributes of that entity as a student and as a person. Notice that an entity may exist in several
leaf nodes of the hierarchy, where a leaf node is a class that has no subclasses of its own. For
example, a member of graduate_student may also be a member of research_assistant.
A subclass with more than one superclass is called a shared subclass, such as
engineering_manager in Figure 4.6. This leads to the concept known as multiple inheritance,
where the shared subclass engineering_manager directly inherits attributes and relationships
from multiple superclasses. Notice that the existence of at least one shared subclass leads to a
lattice (and hence to multiple inheritance); if no shared subclasses existed, we would have a
hierarchy rather than a lattice and only single inheritance would exist. An important rule related
to multiple inheritance can be illustrated by the example of the shared subclass
student_assistant in Figure 4.7, which inherits attributes from both employee and student. Here,
both employee and student inherit the same attributes from person. The rule states that if an
attribute (or relationship) originating in the same superclass (person) is inherited more than
once via different paths (employee and student) in the lattice, then it should be included only
once in the shared subclass (student_assistant). Hence, the attributes of person are inherited
only once in the student_assistant subclass in Figure 4.7.
It is important to note here that some models and languages are limited to single inheritance
and do not allow multiple inheritance (shared subclasses). It is also important to note that some
models do not allow an entity to have multiple types, and hence an entity can be a member of
only one leaf class.8 In such a model, it is necessary to create additional subclasses as leaf
nodes to cover all possible combinations of classes that may have some entity that belongs to
all these classes simultaneously. For example, in the overlapping specialization of person into
{employee, alumnus, student} (or {E, A, S} for short), it would be necessary to create seven
subclasses of person in order to cover all possible types of entities: E, A, S, E_A, E_S, A_S,
and E_A_S. Obviously, this can lead to extra complexity.
Although we have used specialization to illustrate our discussion, similar concepts apply
equally to generalization, as we mentioned at the beginning of this section. Hence, we can also
speak of generalization hierarchies and generalization lattices.
Now we elaborate on the differences between the specialization and generalization processes
and how they are used to refine conceptual schemas during conceptual database design. In the
specialization process, the database designers typically start with an entity type and then define
subclasses of the entity type by successive specialization; that is, they repeatedly define more
specific groupings of the entity type. For example, when designing the specialization lattice in
figure 4.7, we may first specify an entity type person for a university database. Then we
discover that three types of persons will be represented in the database: university employees,
alumni, and students and we create the specialization {employee, alumnus, student}. The
overlapping constraint is chosen because a person may belong to more than one of the
subclasses. We specialize employee further into {staff, faculty, student_assistant}, and
specialize student into {graduate_student, undergraduate_student}. Finally, we specialize
student_assistant into {research_assistant, teaching_assistant}. This process is called top-down
conceptual refinement. So far, we have a hierarchy; then we realize that student_assistant is a
shared subclass, since it is also a subclass of student, leading to the lattice.
It is possible to arrive at the same hierarchy or lattice from the other direction. In such a case,
the process involves generalization rather than specialization and corresponds to a bottom-up
conceptual synthesis. For example, the database designers may first discover entity types such
as staff, faculty, alumnus, graduate_student, undergraduate_student, research_assistant,
teaching_assistant, and so on; then they generalize {graduate_student, undergraduate_student}
into student; then {research_assistant, teaching_assistant} into student_assistant; then {staff,
faculty, student_assistant} into employee; and finally {employee, alumnus, student} into
person.
The final design of hierarchies or lattices resulting from either process may be identical; the
only difference relates to the manner or order in which the schema superclasses and subclasses
were created during the design process. In practice, it is likely that a combination of the two
processes is employed. Notice that the notion of representing data and knowledge by using
superclass/subclass hierarchies and lattices is quite common in knowledge-based systems and
expert systems, which combine database technology with artificial intelligence techniques. For
example, frame-based knowledge representation schemes closely resemble class hierarchies.
Specialization is also common in software engineering design methodologies that are based on
the object-oriented paradigm.
It is sometimes necessary to represent a collection of entities from different entity types. In this
case, a subclass will represent a collection of entities that is a subset of the union of entities
from distinct entity types; we call such a subclass a union type or a category.
For example, suppose that we have three entity types: person, bank, and company. In a
database for motor vehicle registration, an owner of a vehicle can be a person, a bank (holding
a lien on a vehicle), or a company. We need to create a class (collection of entities) that includes
entities of all three types to play the role of vehicle owner. A category (union type) owner that
is a subclass of the union of the three entity sets of company, bank, and person can be created
for this purpose. We display categories in an eer diagram as shown in figure 4.8. The
superclasses company, bank, and person are connected to the circle with the ∪ symbol, which
stands for the set union operation. An arc with the subset symbol connects the circle to the
(subclass) owner category. In figure 4.8 we have two categories: owner, which is a subclass
(subset) of the union of person, bank, and company; and registered_vehicle, which is a subclass
(subset) of the union of car and truck.
A category has two or more superclasses that may represent collections of entities from distinct
entity types, whereas other superclass/subclass relationships always have a single superclass.
To better understand the difference, we can compare a category, such as owner in figure 4.8,
with the engineering_manager shared subclass in figure 4.6. The latter is a subclass of each of
the three superclasses engineer, manager, and salaried_employee, so an entity that is a member
of engineering_manager must exist in all three collections. This represents the constraint that
an engineering manager must be an engineer, a manager, and a salaried_employee; that is, the
engineering_manager entity set is a subset of the intersection of the three entity sets. On the
other hand, a category is a subset of the union of its superclasses. Hence, an entity that is a
member of owner must exist in only one of the superclasses. This represents the constraint that
an owner may be a company, a bank, or a person in figure 4.8.
MODEL PENINGKATAN-HUBUNGAN (EER)
Konsep pemodelan ER yang dibahas dalam Bab 3 cukup untuk mewakili banyak skema basis
data untuk aplikasi basis data tradisional, yang mencakup banyak aplikasi pemrosesan data
dalam bisnis dan industri. Namun, sejak akhir 1970-an, perancang aplikasi database telah
mencoba merancang skema database yang lebih akurat yang mencerminkan properti data dan
kendala dengan lebih tepat. Ini sangat penting untuk aplikasi teknologi database yang lebih
baru, seperti database untuk desain dan manufaktur teknik (CAD / CAM) , 1 telekomunikasi,
sistem perangkat lunak yang kompleks, dan sistem informasi geografis (SIG), di antara banyak
aplikasi lainnya. Database jenis ini memiliki persyaratan yang lebih kompleks daripada
aplikasi yang lebih tradisional. Ini mengarah pada pengembangan konsep pemodelan data
semantik tambahan yang dimasukkan ke dalam model data konseptual seperti model
ER. Berbagai model data semantik telah diusulkan dalam literatur. Banyak dari konsep ini juga
dikembangkan secara independen di bidang terkait ilmu komputer, seperti bidang representasi
pengetahuan kecerdasan buatan dan area pemodelan objek dalam rekayasa perangkat lunak.
Dalam bab ini, kami menjelaskan fitur yang telah diusulkan untuk model data semantik dan
menunjukkan bagaimana model ER dapat ditingkatkan untuk memasukkan konsep-konsep ini,
yang mengarah ke model ER (EER) yang disempurnakan.2 Kita mulai di Bagian 4.1 dengan
memasukkan konsep-konsep hubungan kelas / subkelas dan ketik pewarisan ke dalam model
ER. Kemudian, di Bagian 4.2, kami menambahkan konsep spesialisasi dan
generalisasi. Bagian 4.3 membahas berbagai jenis kendala pada spesialisasi / generalisasi, dan
Bagian 4.4 menunjukkan bagaimana konstruksi UNION dapat dimodelkan dengan
memasukkan konsep kategori dalam model EER. Bagian 4.5 memberikan contoh skema
database UNIVERSITY dalam model EER dan merangkum konsep-konsep model EER
dengan memberikan definisi formal. Kita akan menggunakan istilah objek dan entitas secara
bergantian dalam bab ini, karena banyak dari konsep ini umumnya digunakan dalam model
yang berorientasi objek .
Kami menyajikan notasi diagram kelas UML untuk mewakili spesialisasi dan generalisasi di
Bagian 4.6, dan kami membandingkannya secara singkat dengan notasi dan konsep EER. Ini
berfungsi sebagai contoh notasi alternatif, dan merupakan kelanjutan dari Bagian 3.8, yang
menyajikan notasi diagram kelas UML dasar yang sesuai dengan model ER dasar. Dalam
Bagian 4.7, kami membahas abstraksi mendasar yang digunakan sebagai dasar dari banyak
model data semantik. Bagian 4.8 merangkum bab ini.
Untuk pengantar rinci untuk pemodelan konseptual, Bab 4 harus dianggap sebagai kelanjutan
dari Bab 3. Namun, jika hanya pengantar dasar untuk pemodelan ER yang diinginkan, bab ini
dapat dihilangkan. Atau, pembaca dapat memilih untuk melewati beberapa atau semua bagian
selanjutnya dari bab ini (Bagian 4.4 hingga 4.8).
4.1 SUBCLASS, SUPERCLASS, DAN Warisan
Model EER mencakup semua konsep pemodelan model ER yang disajikan pada Bab 3. Selain
itu, mencakup konsep subkelas dan superclass dan konsep terkait spesialisasi dan generalisasi
(lihat Bagian 4.2 dan 4.3). Konsep lain yang termasuk dalam model EER adalah bahwa dari
kategori atau tipe gabungan (lihat Bagian 4.4), yang digunakan untuk mewakili kumpulan
objek (entitas) yang merupakan gabungan objek dari berbagai tipe entitas. Terkait dengan
konsep-konsep ini adalah mekanisme penting atribut dan hubungan warisan. Sayangnya, tidak
ada terminologi standar untuk konsep-konsep ini, jadi kami menggunakan terminologi yang
paling umum. Terminologi alternatif diberikan dalam catatan kaki. Kami juga menjelaskan
teknik diagram untuk menampilkan konsep-konsep ini ketika mereka muncul dalam skema
EER. Kami menyebut diagram skema yang dihasilkan diagram ER atau EER yang
ditingkatkan.
Konsep model ER yang disempurnakan pertama yang kita ambil adalah subtipe atau
subkelas dari tipe entitas. Seperti yang kita bahas di Bab 3, nama jenis entitas digunakan untuk
mewakili kedua jenis entitas dan kumpulan entitas atau kumpulan entitas jenis itu yang ada
dalam database. Sebagai contoh, karyawan tipe entitas menggambarkan tipe (yaitu, atribut dan
hubungan) dari masing-masing entitas karyawan, dan juga merujuk ke set entitas karyawan
saat ini dalam database perusahaan. Dalam banyak kasus, tipe entitas memiliki banyak
subkelompok atau subtipe entitasnya yang bermakna dan perlu diwakili secara eksplisit karena
signifikansinya terhadap aplikasi basis data. Sebagai contoh, entitas yang merupakan anggota
dari karyawan tipe entitas dapat dibedakan lebih lanjut menjadi sekretaris, insinyur, manajer,
teknisi, salaried_employee, hourly_employee, dan sebagainya. Himpunan atau kumpulan
entitas dalam setiap pengelompokan yang terakhir adalah himpunan bagian dari entitas yang
dimiliki oleh kumpulan entitas karyawan, artinya setiap entitas yang merupakan anggota dari
salah satu sub pengelompokan ini juga merupakan karyawan. W e memanggil masing-masing
pengelompokan ini sebuah subkelas atau subtipe dari tipe entitas karyawan, dan tipe entitas
karyawan disebut superclass atau supertype untuk masing-masing subkelas ini.Gambar 4.1
menunjukkan bagaimana merepresentasikan konsep-konsep ini secara diagram dalam diagram
EER. (Notasi lingkaran pada Gambar 4.1 akan dijelaskan pada Bagian 4.2.)
Kami menyebut hubungan antara superclass dan salah satu dari subkelasnya sebagai
superclass / subclass atau supertype / subtype atau hanya hubungan kelas / subclass.3 Dalam
contoh kami sebelumnya, karyawan / sekretaris dan karyawan / teknisi adalah dua hubungan
kelas / subkelas. Perhatikan bahwa entitas anggota subclass mewakili entitas dunia nyata yang
sama dengan beberapa anggota superclass; misalnya, entitas sekretaris 'Joan Logano ' juga
merupakan karyawan 'Joan Logano .' Oleh karena itu, anggota subclass sama dengan entitas
dalam superclass, tetapi dalam peran spesifik yang berbeda.Ketika kita menerapkan hubungan
superclass / subclass dalam sistem basis data, kita dapat mewakili anggota subclass sebagai
objek basis data yang berbeda — katakanlah, catatan berbeda yang terkait melalui atribut kunci
ke entitas superclassnya. Dalam Bagian 9.2, kami membahas berbagai opsi untuk mewakili
hubungan superclass / subclass dalam database relasional.
Entitas tidak bisa ada dalam database hanya dengan menjadi anggota subkelas; itu juga harus
menjadi anggota superclass. Entitas semacam itu dapat dimasukkan secara opsional sebagai
anggota dari sejumlah subclass. Sebagai contoh, seorang karyawan bergaji yang juga seorang
insinyur termasuk dalam dua subkelas insinyur dan karyawan yang digaji dari jenis entitas
karyawan. Namun, tidak perlu bahwa setiap entitas dalam superclass adalah anggota dari
beberapa subclass.
Konsep penting yang terkait dengan subclass (subtipe) adalah bahwa jenis warisan . Ingatlah
bahwa tipe entitas didefinisikan oleh atribut yang dimilikinya dan tipe hubungan yang
diikutinya. Karena entitas dalam subkelas mewakili entitas dunia nyata yang sama dari
superclass, entitas harus memiliki nilai untuk atribut spesifiknya serta nilai atributnya sebagai
anggota superclass. Kami mengatakan bahwa entitas yang merupakan anggota subkelas
mewarisi semua atribut entitas sebagai anggota dari superclass. Entitas juga mewarisi semua
hubungan di mana superclass berpartisipasi. Perhatikan bahwa subclass, dengan atribut dan
hubungan spesifik (atau lokal) sendiri bersama dengan semua atribut dan hubungan yang
diwarisi dari superclass, dapat dianggap sebagai tipe entitas dalam haknya sendiri .
4.2.1 Spesialisasi
Spesialisasi adalah proses pendefinisian sekumpulan subkelas dari tipe entitas; tipe entitas ini
disebut superclass dari spesialisasi. Himpunan subclass yang membentuk spesialisasi
didefinisikan berdasarkan beberapa karakteristik yang membedakan entitas dalam
superclass. Sebagai contoh, himpunan subclass{sekretaris, insinyur, teknisi } adalah
spesialisasi karyawan superclass yang membedakan antara entitas karyawan berdasarkan jenis
pekerjaan masing-masing karyawan. Kami mungkin memiliki beberapa spesialisasi dengan
jenis entitas yang sama berdasarkan karakteristik pembeda yang berbeda.Misalnya, spesialisasi
lain of jenis entitas karyawan dapat menghasilkan
himpunan subclass {salaried_employee, hourly_employee}; spesialisasi ini membedakan
antara karyawan berdasarkan metode pembayaran.
Gambar 4.1 menunjukkan bagaimana kami menghadirkan spesialisasi secara diagram dalam
diagram EER. Subkelas yang menentukan spesialisasi dilampirkan oleh garis ke lingkaran
yang mewakili spesialisasi, yang terhubung pada gilirannya ke superclass. Simbol subset pada
setiap baris yang menghubungkan subclass ke lingkaran menunjukkan arah hubungan
superclass / subclass.5 Atribut yang hanya berlaku untuk entitas subclass tertentu —
seperti TypingSpeed of secretary — melekat pada persegi panjang yang mewakili subclass
itu. Ini disebut atribut subclass spesifik (atau lokal). Demikian pula, subkelas dapat
berpartisipasi dalam tipe hubungan tertentu, seperti subkelas hourly_employee
yang berpartisipasi dalam milik_to hubungan pada Gambar 4.1. Kami akan menjelaskan
simbol d di lingkaran pada Gambar 4.1 dan notasi diagram EER tambahan segera.
Gambar 4.2 menunjukkan beberapa instance entitas yang termasuk subclass dari spesialisasi
{sekretaris, insinyur, teknisi}. Sekali lagi, perhatikan bahwa entitas yang dimiliki oleh subclass
mewakili entitas dunia nyata yang sama dengan entitas yang terhubung dengannya dalam
superclass EMPLOYEE, meskipun entitas yang sama ditampilkan dua kali; misalnya, e1
ditunjukkan pada karyawan dan sekretaris pada Gambar 4.2. Seperti yang ditunjukkan oleh
gambar, hubungan superclass / subclass seperti karyawan / sekretaris agak menyerupai
hubungan 1: 1 pada tingkat instance (lihat Gambar 3.12).Perbedaan utama adalah bahwa dalam
hubungan 1: 1 dua entitas yang berbeda saling terkait, sedangkan dalam hubungan superclass
/ subclass entitas dalam subclass adalah entitas dunia nyata yang sama dengan entitas dalam
superclass tetapi memainkan peran khusus — untuk misalnya, seorang karyawan yang
berspesialisasi dalam peran sekretaris, atau seorang karyawan yang berspesialisasi dalam peran
teknisi.
Ada dua alasan utama untuk menyertakan hubungan kelas dan subkelas dan spesialisasi. Yang
pertama adalah bahwa atribut tertentu dapat berlaku untuk beberapa tetapi tidak semua
entitas tipe entitas superclass. Subclass didefinisikan untuk mengelompokkan entitas yang
menerapkan atribut ini. Anggota subclass mungkin masih berbagi sebagian besar atribut
mereka dengan anggota superclass lainnya. Sebagai contoh, pada Gambar 4.1 sekretaris
subclass memiliki atribut spesifik Typing_speed , sedangkan subkelas insinyur memiliki
atribut spesifik Eng_type , tetapi sekretaris dan insinyur berbagi atribut warisan lainnya dari
jenis entitas karyawan.
Alasan kedua untuk menggunakan subclass adalah bahwa beberapa tipe hubungan dapat
berpartisipasi hanya oleh entitas yang merupakan anggota subclass. Misalnya, jika
hanya hourly_employees dapat menjadi milik serikat pekerja, kita dapat mewakili kenyataan
bahwa dengan menciptakanhourly_employee subclass dari karyawan dan berkaitan subclass
untuk entitas jenis trade_union melalui belongs_to jenis hubungan, seperti digambarkan pada
Gambar 4.1.
4.2.2 Generalisasi
Kita dapat memikirkan proses abstraksi terbalik di mana kita menekan perbedaan di antara
beberapa jenis entitas, mengidentifikasi fitur-fitur umum mereka, dan menggeneralisasikannya
menjadi sebuah superclass tunggal yang jenis entitas aslinya adalah subclass khusus. Sebagai
contoh, perhatikanjenis entitas mobil dan truk yang ditunjukkan pada Gambar 4.3 (a). Karena
mereka memiliki beberapa atribut umum, mereka dapat digeneralisasikan ke
dalam kendaraan jenis entitas , seperti yang ditunjukkan pada Gambar 4.3 (b). Baik mobil dan
truk sekarang menjadi subclass dari kendaraan superclass umum. Kami menggunakan istilah
generalisasi untuk merujuk pada proses mendefinisikan jenis entitas umum dari jenis entitas
yang diberikan.
Perhatikan bahwa proses generalisasi dapat dipandang sebagai kebalikan dari proses
spesialisasi secara fungsional; kita dapat melihat {mobil, truk} sebagai spesialisasi kendaraan
daripada memandang kendaraan sebagai geografi mobil dan truk. Sebuah notasi diagram untuk
membedakan antara generalisasi dan spesialisasi digunakan di beberapa metodologi
desain. Panah yang menunjuk ke superclass yang digeneralisasi mewakili proses generalisasi,
sedangkan panah yang menunjuk ke subclass khusus mewakili proses spesialisasi. Kami tidak
akan menggunakan notasi ini karena keputusan mengenai proses mana yang diikuti dalam
situasi tertentu seringkali subyektif.
Sejauh ini kami telah memperkenalkan konsep subclass dan hubungan superclass / subclass,
serta proses spesialisasi dan generalisasi. Secara umum, superclass atau subclass mewakili
kumpulan entitas dengan tipe yang sama dan karenanya juga menjelaskan tipe entitas; itu
sebabnya superclasses dan subclass semuanya ditampilkan dalam persegi panjang dalam
diagram EER, seperti jenis entitas.
Pertama, kami membahas kendala yang berlaku untuk spesialisasi tunggal atau generalisasi
tunggal. Untuk singkatnya, diskusi kami hanya mengacu pada spesialisasi meskipun berlaku
untuk spesialisasi dan generalisasi. Kemudian, kami membahas perbedaan antara spesialisasi /
generalisasi kisi (multiple inheritance) dan hierarki (single inheritance), dan kami menguraikan
perbedaan antara proses spesialisasi dan generalisasi selama desain skema database konseptual.
Secara umum, kami mungkin memiliki beberapa spesialisasi yang didefinisikan pada tipe
entitas yang sama (atau superclass), seperti yang ditunjukkan pada Gambar 4.1. Dalam kasus
seperti itu, entitas dapat menjadi bagian dari subclass di masing-masing
spesialisasi. Spesialisasi juga dapat terdiri dari satu subkelas saja, seperti spesialisasi
{manager} pada Gambar 4.1; dalam kasus seperti itu, kami tidak menggunakan notasi
lingkaran.
Dalam beberapa spesialisasi kita dapat menentukan dengan tepat entitas yang akan menjadi
anggota dari setiap subclass dengan menempatkan suatu kondisi pada nilai beberapa atribut
dari superclass. Subclass tersebut disebut subclass yang ditentukan oleh predikat (atau yang
ditentukan oleh kondisi).Sebagai contoh, jika tipe entitas karyawan memiliki atribut Job_type ,
seperti yang ditunjukkan pada Gambar 4.4, kita dapat menentukan kondisi keanggotaan
dalam subkelas sekretaris berdasarkan kondisi ( Job_type = 'Sekretaris'), yang kami sebut
predikat pendefinisian subclass . Kondisi ini merupakan batasan yang menentukan bahwa
entitas-entitas dari tipe entitas karyawan yang memiliki nilai atribut untuk Job_type adalah
'Sekretaris' milik subclass. Kami menampilkan subclass yang ditentukan oleh predikat dengan
menulis kondisi predikat di sebelah garis yang menghubungkan subclass ke lingkaran
spesialisasi.
Jika semua subclass dalam spesialisasi memiliki kondisi keanggotaan mereka pada atribut yang
sama dari superclass, spesialisasi itu sendiri disebut spesialisasi yang ditentukan atribut, dan
atribut tersebut disebut atribut pendefinisian spesialisasi. Dalam hal ini, semua entitas dengan
nilai yang sama untuk atribut milik subclass yang sama. Kami menampilkan spesialisasi
atribut-didefinisikan dengan menempatkan nama atribut yang menentukan di sebelah busur
dari lingkaran ke superclass, seperti yang ditunjukkan pada Gambar 4.4.
Ketika kita tidak memiliki ketentuan untuk menentukan keanggotaan dalam subkelas, maka
subkelas tersebut disebut pengguna-ditentukan. Keanggotaan dalam subkelas tersebut
ditentukan oleh pengguna basis data ketika mereka menerapkan operasi untuk menambahkan
entitas ke dalam subkelas;karenanya, keanggotaan ditentukan secara individual untuk setiap
entitas oleh pengguna, bukan oleh kondisi apa pun yang dapat dievaluasi secara otomatis.
Batasan kedua pada spesialisasi disebut batasan kelengkapan (atau totalitas ), yang mungkin
total atau parsial. Batasan spesialisasi total menentukan bahwa setiap entitas dalam superclass
harus menjadi anggota setidaknya satu subkelas dalam spesialisasi. Misalnya, jika setiap
karyawan harus berupajam _employee o ra salaried_employee, maka spesialisasi {hourly_em
ployee, salaried_employee} pada gambar 4.1 adalah spesialisasi total karyawan. Ini
ditunjukkan dalam diagram EER dengan menggunakan garis ganda untuk menghubungkan
superclass ke lingkaran. Satu baris digunakan untuk menampilkan spesialisasi parsial, yang
memungkinkan suatu entitas tidak menjadi bagian dari subkelas. Sebagai contoh, jika beberapa
entitas karyawan bukan milik subclass {sekretaris, insinyur, teknisi } dalam Gambar 4.1 dan
4.4, maka spesialisasi itu adalah bagian l.
Perhatikan bahwa kendala ketidakjelasan dan kelengkapan bersifat independen. Oleh karena
itu, kami memiliki empat batasan yang mungkin terjadi pada spesialisasi:
■ Terpisah , total
■ Terpisah, parsial
Tentu saja, batasan yang benar ditentukan dari makna dunia nyata yang berlaku untuk masing-
masing spesialisasi. Secara umum, superclass yang diidentifikasi melalui proses generalisasi
biasanya total, karena superclass berasal dari subclass dan karenanya hanya berisi entitas yang
ada di dalam subclass.
Aturan penyisipan dan penghapusan tertentu berlaku untuk spesialisasi (dan generalisasi)
sebagai konsekuensi dari kendala yang ditentukan sebelumnya.Beberapa aturan ini adalah
sebagai berikut:
■ Menghapus entitas dari superclass menyiratkan bahwa entitas itu secara otomatis dihapus
dari semua subclass yang menjadi miliknya.
■ Memasukkan entitas dalam superclass menyiratkan bahwa entitas dimasukkan secara wajib
dalam semua subkelas yang ditentukan oleh predikat (atau yang ditentukan oleh atribut) di
mana entitas tersebut memenuhi predikat yang ditentukan.
■ Memasukkan entitas dalam superclass dari spesialisasi total menyiratkan bahwa entitas
wajib dimasukkan ke dalam setidaknya satu dari subclass spesialisasi.
Pembaca didorong untuk membuat daftar aturan lengkap untuk penyisipan dan penghapusan
untuk berbagai jenis spesialisasi.
Subclass itu sendiri mungkin memiliki subclass lebih lanjut yang ditentukan di atasnya,
membentuk hierarki atau kisi spesialisasi. Sebagai contoh, pada Gambar 4.6 insinyur adalah
subkelas karyawan dan juga merupakan superclass of engineering_manager ; ini merupakan
kendala dunia nyata yang harus dimiliki oleh setiap manajer teknik untuk menjadi
insinyur. Hirarki spesialisasi memiliki batasan bahwa setiap subclass berpartisipasi sebagai
subclass hanya dalam satu hubungan kelas / subclass; yaitu, setiap subkelas hanya memiliki
satu induk, yang menghasilkan struktur pohon atau hierarki yang ketat.Sebaliknya,
untuk kisi spesialisasi , subkelas dapat menjadi subkelas di lebih dari satu hubungan kelas /
subkelas. Oleh karena itu, Gambar 4.6 adalah sebuah kisi.
Gambar 4.7 menunjukkan kisi spesialisasi lain lebih dari satu level. Ini mungkin bagian dari
skema konseptual untuk database universitas. Perhatikan bahwa pengaturan ini akan menjadi
hierarki kecuali untuk subclass student_assistant , yang merupakan subclass dalam dua
hubungan kelas / subclass yang berbeda.
Persyaratan untuk bagian dari database UNIVERSITY yang ditunjukkan pada Gambar 4.7
adalah sebagai berikut:
1. Basis data melacak tiga jenis orang: karyawan, alumni, dan mahasiswa. Seseorang dapat
memiliki satu, dua, atau ketiga tipe ini. Setiap orang memiliki nama, SSN, jenis kelamin,
alamat, dan tanggal lahir.
2. Setiap karyawan memiliki gaji, dan ada tiga jenis karyawan: staf pengajar, staf, dan asisten
mahasiswa. Setiap karyawan memiliki salah satu dari jenis-jenis ini. Untuk setiap alumnus,
catatan gelar atau gelar yang dia dapatkan di universitas disimpan, termasuk nama gelar, tahun
yang diberikan, dan departemen utama. Setiap siswa memiliki jurusan utama.
3. Setiap fakultas memiliki peringkat, sedangkan setiap anggota staf memiliki posisi
staf. Asisten siswa diklasifikasikan lebih lanjut sebagai asisten penelitian atau asisten pengajar,
dan persentase waktu mereka bekerja dicatat dalam database. Asisten penelitian menyimpan
proyek penelitiannya, sedangkan asisten pengajar memiliki program studi saat ini.
4. Siswa selanjutnya diklasifikasikan sebagai lulusan atau sarjana, dengan program gelar atribut
khusus (MS, Ph.D., MBA, dan sebagainya) untuk mahasiswa pascasarjana dan kelas
(mahasiswa baru, mahasiswa kedua, dan sebagainya) untuk mahasiswa sarjana.
Pada Gambar 4.7, semua entitas orang yang diwakili dalam database adalah anggota dari tipe
entitas orang , yang dikhususkan ke dalam subkelas{karyawan, alumnus, siswa }. Spesialisasi
ini tumpang tindih; misalnya, seorang alumni juga dapat menjadi karyawan dan siswa yang
mengejar gelar lanjutan. Siswa subclass adalah superclass untuk spesialisasi
{ graduate_student , undergraduate_student }, sedangkan karyawan adalah superclass untuk
spesialisasi { student_assistant , fakultas, staf}. Perhatikan bahwa siswa _assistant juga
merupakan subkelas siswa. Akhirnya, student_assistant adalah superclass untuk spesialisasi ke
{ research_assistan t , mengajar _assistant }.
Dalam kisi atau hierarki spesialisasi seperti itu, subkelas mewarisi atribut tidak hanya dari
superclass langsungnya, tetapi juga dari semua superclassespendahulunya sampai ke akar
hierarki atau kisi jika perlu. Sebagai contoh, sebuah entitas dalam _student lulusan mewarisi
semua atribut dari entitas yang sebagai mahasiswa dan sebagai pribadi. Perhatikan bahwa
entitas mungkin ada di beberapa node daun dari hierarki, di mana node daun adalah kelas yang
tidak memiliki subclass sendiri. Sebagai contoh, seorang anggota graduate_student juga dapat
menjadi anggota research_assistant .
Penting untuk dicatat di sini bahwa beberapa model dan bahasa terbatas pada pewarisan tunggal
dan tidak memungkinkan pewarisan berganda (subclass bersama). Penting juga untuk dicatat
bahwa beberapa model tidak memungkinkan suatu entitas memiliki banyak tipe, dan karenanya
suatu entitas dapat menjadi anggota dari hanya satu kelas daun.8 Dalam model seperti itu, perlu
untuk membuat subkelas tambahan sebagai simpul daun untuk tutupi semuakemungkinan
kombinasi kelas yang mungkin memiliki beberapa entitas yang dimiliki oleh semua kelas ini
secara bersamaan. Misalnya, dalam spesialisasi orang yang tumpang tindih menjadi
{karyawan, alumnus, siswa} (atau {E, A, S} singkatnya), akan diperlukan untuk membuat
tujuh subkelas orang untuk mencakup semua jenis entitas yang mungkin: E, A, S, E_A, E_S,
A_S, dan E_A_S. Jelas, ini dapat menyebabkan kompleksitas tambahan.
Meskipun kami telah menggunakan spesialisasi untuk menggambarkan diskusi kami, konsep
yang sama berlaku untuk generalisasi, seperti yang kami sebutkan di awal bagian ini. Oleh
karena itu, kita juga dapat berbicara tentang hierarki generalisasi dan kisi generalisasi.
Sekarang kami menguraikan perbedaan antara proses spesialisasi dan generalisasi dan
bagaimana mereka digunakan untuk memperbaiki skema konseptual selama desain database
konseptual. Dalam proses spesialisasi, perancang basis data biasanya mulai dengan tipe entitas
dan kemudian menentukan subclass dari tipe entitas dengan spesialisasi berturut-turut; yaitu,
mereka berulang kali mendefinisikan pengelompokan yang lebih spesifikdari tipe
entitas. F atau contoh, ketika merancang kisi spesialisasi dalam gambar 4.7, kita mungkin
pertama menentukan orang entitas tipe untuk database universitas. Kemudian kami
menemukan bahwa tiga tipe orang akan terwakili dalam database: karyawan universitas,
alumni, dan mahasiswa dan kami menciptakan spesialisasi {karyawan,
alumnus, mahasiswa }. Batasan yang tumpang tindih dipilih karena seseorang
dapat memiliki lebih dari satu subkelas. Kami mengkhususkan karyawan lebih lanjut ke
{ staff, fakultas, student_assistant }, dan mengkhususkan siswa ke
{ graduate_student ,undergraduate_student }. Akhirnya, kami
menspesialisasikan student_assistant ke dalam
{ research_assistant , teaching_assistant }. Proses ini disebut penyempurnaan konseptual top-
down. Sejauh ini, kami memiliki hierarki; kemudian kami menyadari
bahwa student_assistant adalah subclass bersama, karena itu juga merupakan subclass dari
siswa, yang mengarah ke kisi.
Dimungkinkan untuk sampai pada hierarki atau kisi yang sama dari arah lain. Dalam kasus
seperti itu, proses melibatkan generalisasi daripada spesialisasi dan sesuai dengan sintesis
konseptual bottom-up. Sebagai contoh, perancang basis data pertama-tama dapat menemukan
jenis entitas seperti staf, staf pengajar,
alumni, lulusan_pelajar , sarjana_pelajar , peneliti_pelindung , pengajar_pelindung , dan
sebagainya; kemudian mereka menggeneralisasi {graduate_student , undergraduate_student }
menjadi mahasiswa; kemudian { research_assistant , teaching_assistant }
ke student_as sistant ; kemudian {staff, fakultas, student_assistant } menjadi karyawan; dan
akhirnya {karyawan, alumni, mahasiswa} menjadi pribadi.
Desain akhir hierarki atau kisi yang dihasilkan dari kedua proses tersebut mungkin
identik; satu-satunya perbedaan berkaitan dengan cara atau urutan di mana
skema superclasses dan subclass dibuat selama proses desain. Dalam praktiknya, ada
kemungkinan bahwa kombinasi dari kedua proses tersebut digunakan. Perhatikan
bahwa Gagasan untuk merepresentasikan data dan pengetahuan dengan menggunakan hierarki
dan kisi superclass / subclass cukup umum dalam sistem berbasis pengetahuan dan sistem
pakar, yang menggabungkan teknologi basis data dengan teknik kecerdasan buatan. Misalnya,
skema representasi pengetahuan berbasis bingkai sangat mirip dengan hierarki
kelas. Spesialisasi juga umum dalam metodologi desain rekayasa perangkat lunak yang
didasarkan pada paradigma berorientasi objek.
Misalnya, anggaplah kita memiliki tiga jenis entitas: orang, bank, dan perusahaan . Dalam
database untuk pendaftaran kendaraan bermotor, pemilik kendaraan dapat berupa orang, bank
(memegang gadai pada kendaraan), atau perusahaan. Kita perlu membuat kelas (kumpulan
entitas) yang mencakup entitas dari ketiga jenis untuk memainkan peran pemilik
kendaraan. Pemilik kategori (tipe serikat) yang merupakan subkelas dari gabungan tiga set
entitas perusahaan, bank, dan orang dapat dibuat untuk tujuan ini. Kami menampilkan kategori
dalam diagram eer seperti yang ditunjukkan pada gambar
4.8.Superclasses perusahaan, perbankan, dan orang yang terhubung ke lingkaran
dengan ∪ simbol, yang merupakan singkatan dari operasi set serikat. Sebuah busur dengan
simbol subset menghubungkan lingkaran ke kategori pemilik (subclass). Pada Gambar 4.8
kami memiliki dua kategori: pemilik, yang merupakan subkelas (subset) dari persatuan orang,
bank, dan perusahaan; dan Registered_vehicle , yang merupakan subclass (subset) dari
penyatuan mobil dan truk.
Suatu kategori memiliki dua atau lebih superclass yang dapat mewakili koleksi entitas dari tipe
entitas yang berbeda, sedangkan hubungan superclass / subclass lainnya selalu memiliki
superclass tunggal. Untuk lebih memahami perbedaannya , kita dapat membandingkan
kategori, seperti pemilik pada gambar 4.8, dengan subclass yang
dibagikan engineering_manager pada gambar 4.6. Yang terakhir adalah subkelas dari masing-
masing dari tigasuperclasses engineer, manager, dan salar ied_employee , sehingga entitas
yang merupakan anggota dari engineering_manager harus ada di ketiga koleksi. Ini mewakili
kendala bahwa seorang manajer teknik harus seorang insinyur, manajer, dan
seorang karyawan yang digaji ; yaitu, rekayasa_manager himpunan entitas adalah bagian dari
persimpangan tiga set entitas. Di sisi lain, kategori adalah bagian dari gabungan
dari superclasses -nya .Oleh karena itu, entitas yang merupakan anggota pemilik harus ada
hanya di salah satu superclasses . Ini mewakili kendala bahwa pemilik dapat berupa
perusahaan, bank, atau orang dalam Gambar 4.8.
Gambar 4.8 Dua kategori (tipe gabungan): PEMILIK dan REGISTERED_VEHICLE.
Atribut turunan bekerja lebih selektif dalam hal kategori. Sebagai contoh, pada Gambar 4.8,
setiap entitas PEMILIK mewarisi atribut-atribut PERUSAHAAN, ORANG, atau BANK,
tergantung pada superclass tempat entitas tersebut berada. Di sisi lain, subclass bersama seperti
ENGINEERING_MANAGER (Gambar 4.6) mewarisi semua atribut dari superclasses
SALARIED_EMPLOYEE, ENGINEER, dan MANAGER.
Sangat menarik untuk mencatat perbedaan antara kategori REGISTERED_VEHICLE
(Gambar 4.8) dan VEHICLE superclass umum (Gambar 4.3 (b)). Pada Gambar 4.3 (b), setiap
mobil dan setiap truk adalah KENDARAAN; tetapi pada Gambar 4.8, kategori
REGISTERED_VEHICLE mencakup beberapa mobil dan beberapa truk tetapi belum tentu
semuanya (misalnya, beberapa mobil atau truk mungkin tidak terdaftar). Secara umum,
spesialisasi atau generalisasi seperti pada Gambar 4.3 (b), jika parsial, tidak akan menghalangi
KENDARAAN dari mengandung jenis entitas lain, seperti sepeda motor. Namun, kategori
seperti REGISTERED_VEHICLE pada Gambar 4.8 menyiratkan bahwa hanya mobil dan truk,
tetapi bukan jenis entitas lainnya, yang dapat menjadi anggota REGISTERED_VEHICLE.
Kategori dapat total atau sebagian. Kategori total memegang persatuan semua entitas dalam
superclasses, sedangkan kategori parsial dapat menampung subset dari persatuan. Kategori
total direpresentasikan secara diagram dengan garis ganda yang menghubungkan kategori dan
lingkaran, sedangkan kategori parsial ditunjukkan oleh satu garis.
Superclasses dari kategori mungkin memiliki atribut kunci yang berbeda, seperti yang
ditunjukkan oleh kategori PEMILIK pada Gambar 4.8, atau mereka mungkin memiliki atribut
kunci yang sama, seperti yang ditunjukkan oleh kategori REGISTERED_VEHICLE.
Perhatikan bahwa jika suatu kategori adalah total (bukan parsial), ia dapat direpresentasikan
sebagai alternatif total spesialisasi (atau total generalisasi). Dalam hal ini, pilihan representasi
yang digunakan adalah subyektif. Jika dua kelas mewakili tipe entitas yang sama dan berbagi
banyak atribut, termasuk atribut kunci yang sama, spesialisasi / generalisasi lebih disukai; jika
tidak, kategorisasi (jenis serikat) lebih tepat.
Penting untuk dicatat bahwa beberapa metodologi pemodelan tidak memiliki tipe gabungan.
Dalam model-model ini, jenis serikat pekerja harus diwakili secara tidak langsung (lihat Bagian
9.2).
⋃ Si=G
i =1
Kalau tidak, Z dikatakan parsial. Z dikatakan terpisah jika kita selalu punya
Si ∩ Sj = ∅ (empty set) 𝑢𝑛𝑡𝑢𝑘 i ≠ j