Lecture 4
Lecture 4
Ashish Kumar
Dept. of CSE
Manipal University Jaipur
1
Design Issues - 1
Use of Entity Sets versus Attributes
What constitutes an attribute, and what
constitutes an entity set?
The distinctions mainly depend on the structure
of the real-world enterprise being modeled, and
on the semantics associated with the attribute in
question.
A common mistake is to use the primary key of an
entity set as an attribute of another entity set,
instead of using a relationship.
For example, it is incorrect to model customer-id
as an attribute of loan even if each loan had only
one customer.
2
Design Issues - 2
Use of Entity Sets versus Relationship Sets
It is not always clear whether an object is best expressed
by an entity set or a relationship set.
Two problems arise as a result of the replication: (1) the
data are stored multiple times, wasting storage space, and
(2) updates potentially leave the data in an inconsistent
state, where the values differ in two relationships for
attributes that are supposed to have the same value.
One possible guideline in determining whether to use an
entity set or a relationship set is to designate a relationship
set to describe an action that occurs between entities.
This approach can also be useful in deciding whether
certain attributes may be more appropriately expressed as
relationships.
3
Design Issues – 3 & 4
Binary versus n-ary Relationship Sets
Relationships in databases are often binary. Some
relationships that appear to be non-binary could actually be
better represented by several binary relationships. We can
generalize this process in a straightforward manner to n-
ary relationship sets. Thus, conceptually, we can restrict
the E-R model to include only binary relationship sets.
However, this restriction is not always desirable.
Placement of Relationship Attributes
The design decision of where to place descriptive attributes
in such cases—as a relationship or entity attribute—should
reflect the characteristics of the enterprise being modeled.
4
Specialization
An entity set may include sub groupings of entities that are
distinct in some way from other entities in the set.
For instance, a subset of entities within an entity set may
have attributes that are not shared by all the entities in the
entity set.
The E-R model provides a means for representing these
distinctive entity groupings.
The process of designating sub groupings within an entity
set is called specialization.
An entity set may be specialized by more than one
distinguishing feature.
In terms of an E-R diagram, specialization is depicted by a
triangle component labeled ISA.
The label ISA stands for “is a”. The ISA relationship may
also be referred to as a superclass-subclass relationship.
Higher- and lower-level entity sets are depicted as regular
5
Specialization
6
Specialization
Disjoint Vs Overlapping
Specialization
7
Generalization
The refinement from an initial entity set into successive
levels of entity sub groupings represents a top-down
design process in which distinctions are made explicit.
The design process may also proceed in a bottom-up
manner, in which multiple entity sets are synthesized into a
higher-level entity set on the basis of common features.
This commonality can be expressed by generalization,
which is a containment relationship that exists between a
higher-level entity set and one or more lower-level entity
sets.
Higher- and lower-level entity sets also may be designated
by the terms superclass and subclass, respectively.
For all practical purposes, generalization is a simple
inversion of specialization.
8
Aggregation
One limitation of the E-R model is that it cannot express
relationships among relationships.
Aggregation is an abstraction in which relationship sets
(along with their associated entity sets) are treated as
higher-level entity sets, and can participate in
relationships.
9
Example - 1
Construct an E-R diagram for a car-insurance company
whose customers own one or more cars each. Each car has
associated with it zero to any number of recorded
accidents.
10
Example – 2
Construct an E-R diagram for a hospital with a set of
patients and a set of medical doctors. Associate with each
patient a log of the various tests and examinations
conducted.
11
Example - 3
A university registrar’s office maintains data about the
following entities: (a) courses, including number, title,
credits, syllabus, and prerequisites; (b) course offerings,
including course number, year, semester, section number,
instructor(s), timings, and classroom; (c) students,
including student-id, name, and program; and (d)
instructors, including identification number, name,
department, and title. Further, the enrollment of students
in courses and grades awarded to students in each course
they are enrolled for must be appropriately modeled.
Construct an E-R diagram for the registrar’s office.
Document all assumptions that you make about the
mapping constraints.
12
Example - 3
13
Thank You
14