Chapter 4
Chapter 4
• Design Process
• Modeling
• Cardinality Constraints
• E-R Diagram
• Types of Entity Sets
• Design of the University Database
• Examples of ER Diagram
Design Phases
• The initial phase of database design is to
characterize fully the data needs of the prospective
database users.
• Next, the designer chooses a data model and, by
applying the concepts of the chosen data model,
translates these requirements into a conceptual
schema of the database.
• A fully developed conceptual schema also indicates
the functional requirements of the enterprise. In a
“specification of functional requirements”, users
describe the kinds of operations (or transactions)
that will be performed on the data.
Design Phases
The process of moving from an abstract data model to the
implementation of the database proceeds in two final design
phases.
• Logical Design – Deciding on the database schema.
Database design requires that we find a “good” collection
of relation schemas.
– Business decision – What attributes should we record
in the database?
– Computer Science decision – What relation schemas
should we have and how should the attributes be
distributed among the various relation schemas?
• Physical Design – Deciding on the physical layout of
the database
Design Approaches
• Entity Relationship Model
– Models an enterprise as a collection of entities
and relationships
• Entity: a “thing” or “object” in the enterprise that is
distinguishable from other objects
_Described by a set of attributes
• Relationship: an association among several
entities
– Represented diagrammatically by an entity-
relationship diagram
ER model -- Database Modeling
• Binary relationship
– involve two entity sets (or degree two).
– most relationship sets in a database system
are binary.
• Relationships between more than two entity
sets are rare. Most relationships are
binary.
Example: students work on research projects
under the guidance of an instructor.
relationship proj_guide is a ternary relationship
between instructor, student, and project
Mapping Cardinality Constraints
• Attribute types:
– Simple and composite attributes.
– Single-valued and multi-valued attributes
• Example: multi-valued attribute: phone_numbers
– Derived attributes
• Can be computed from other attributes
• Example: age, given date_of_birth
• Domain – the set of permitted values for
each attribute
Composite Attributes
Types of Entity
An entity set may be of the following two types-
In this ER Diagram:
-> Two strong entity sets “Student” and “Course” are related to each other.
-> Student ID is the primary key using which any student can be identified
uniquely.
-> Course ID is the primary key using which any course can be identified
uniquely.
-> Double line between Student and relationship set signifies total
participation.
It suggests that each student must be enrolled in at least one course.
-> Single line between Course and relationship set signifies partial
participation.
It suggests that there might exist some courses for which no enrollments are
made.
Weak Entity Sets
• In a relational database, a weak entity is an entity that
cannot be uniquely identified by its attributes alone;
therefore, it must use a foreign key in conjunction with
its attributes to create a primary key. The foreign key is
typically a primary key of an entity it is related to.
• A weak entity set is an entity set that does not contain
sufficient attributes to uniquely identify its entities. In
other words, a primary key does not exist for a weak
entity set. However, it contains a partial key called as a
discriminator. Discriminator can identify a group
of entities from the entity set.
• Discriminator is represented by underlining with a
dashed line.
Symbols Used Weak Entity Set
A double rectangle is used for representing a weak entity
set.
• A double diamond symbol is used for representing the
relationship that exists between the strong and weak
entity sets and this relationship is known as identifying
relationship.
• A double line is used for representing the connection of
the weak entity set with the relationship set.
• Total participation always exists in the identifying
relationship.
Example Weak Entity
In this ER Diagram:
-> One strong entity set “Building” and one weak entity set “Apartment”
are related to each other..
->Door number is the discriminator of the weak entity set “Apartment”.
->This is because door number alone can not identify an apartment
uniquely as there may be several other buildings having the same door
number.
->Double line between Apartment and relationship set signifies total
participation.
It suggests that each apartment must be present in at least one building.
->Single line between Building and relationship set signifies partial
participation.
It suggests that there might exist some buildings which has no apartment.
Entity Sets
Entities can be represented graphically as follows:
• Rectangles represent entity sets.
• Attributes listed inside entity rectangle
• Underline indicates primary key attributes
Relationship Sets
Diamonds represent relationship sets.
Cardinality Constraints
• We express cardinality constraints by drawing either a
directed line (), signifying “one,”
• or an undirected line (—), signifying “many,” between the
relationship set and the entity set.
• In a many-to-one relationship
between an instructor and a student,
– an instructor is associated with at most
one student via advisor,
– and a student is associated with several
(including 0) instructors via advisor
Many-to-Many Relationship
Building(bname, address)
Floor (floor #, no_apt, bname)
Assumption:
Floor# can be repeated among multiple building