DBMS chp ER Model
DBMS chp ER Model
Design Process
Modeling
Constraints
E-R Diagram
Design Issues
Weak Entity Sets
Extended E-R Features
Design of the Bank Database
Reduction to Relation Schemas
Database Design
UML
Database System Concepts - 6th Edition 7.2 ©Silberschatz, Korth and Sudarshan
Modeling
A database can be modeled as:
a collection of entities,
relationship among entities.
An entity is an object that exists and is distinguishable from
other objects.
Example: specific person, company, event, plant
Entities have attributes
Example: people have names and addresses
An entity set is a set of entities of the same type that share the
same properties.
Example: set of all persons, companies, trees, holidays
Database System Concepts - 6th Edition 7.3 ©Silberschatz, Korth and Sudarshan
Entity Sets instructor and student
ID name ID name
Database System Concepts - 6th Edition 7.4 ©Silberschatz, Korth and Sudarshan
Keys
Database System Concepts - 6th Edition 7.5 ©Silberschatz, Korth and Sudarshan
Relationship Sets
Database System Concepts - 6th Edition 7.6 ©Silberschatz, Korth and Sudarshan
Relationship Set advisor
Database System Concepts - 6th Edition 7.7 ©Silberschatz, Korth and Sudarshan
E-R Diagrams
Database System Concepts - 6th Edition 7.8 ©Silberschatz, Korth and Sudarshan
Relationship Sets With Attributes
An attribute can also be property of a relationship set.
For instance, the advisor relationship set between entity sets
instructor and student may have the attribute date
E.g. date may track when the student started being
associated with the advisor
Database System Concepts - 6th Edition 7.9 ©Silberschatz, Korth and Sudarshan
Relationship Sets with Attributes
Database System Concepts - 6th Edition 7.10 ©Silberschatz, Korth and Sudarshan
Attributes
Database System Concepts - 6th Edition 7.11 ©Silberschatz, Korth and Sudarshan
Composite Attributes
Database System Concepts - 6th Edition 7.12 ©Silberschatz, Korth and Sudarshan
Entity With Composite, Multivalued, and Derived
Attributes
composite
multivalued
derived
Database System Concepts - 6th Edition 7.13 ©Silberschatz, Korth and Sudarshan
Degree of a Relationship Set
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. (More on this later.)
Example: students work on research projects under the
guidance of an instructor.
relationship proj_guide is a ternary relationship between
instructor, student, and project
Database System Concepts - 6th Edition 7.14 ©Silberschatz, Korth and Sudarshan
E-R Diagram with a Ternary Relationship
Database System Concepts - 6th Edition 7.15 ©Silberschatz, Korth and Sudarshan
Mapping Cardinality Constraints
Express the number of entities to which another entity can be
associated via a relationship set.
Most useful in describing binary relationship sets.
For a binary relationship set the mapping cardinality must be
one of the following types:
One to one
One to many
Many to one
Many to many
Database System Concepts - 6th Edition 7.16 ©Silberschatz, Korth and Sudarshan
Mapping Cardinalities
Database System Concepts - 6th Edition 7.17 ©Silberschatz, Korth and Sudarshan
Mapping Cardinalities
Database System Concepts - 6th Edition 7.18 ©Silberschatz, Korth and Sudarshan
ER Notation for Cardinality Constraints
Database System Concepts - 6th Edition 7.19 ©Silberschatz, Korth and Sudarshan
One-to-One Relationship
Database System Concepts - 6th Edition 7.20 ©Silberschatz, Korth and Sudarshan
One-to-Many Relationship
Database System Concepts - 6th Edition 7.21 ©Silberschatz, Korth and Sudarshan
Many-to-One Relationships
Database System Concepts - 6th Edition 7.22 ©Silberschatz, Korth and Sudarshan
Many-to-Many Relationship
An instructor is associated with several (possibly 0)
students via advisor
A student is associated with several (possibly 0)
instructors via advisor
Database System Concepts - 6th Edition 7.23 ©Silberschatz, Korth and Sudarshan
Participation of an Entity Set in a
Relationship Set
Database System Concepts - 6th Edition 7.24 ©Silberschatz, Korth and Sudarshan
Alternative Notation for Cardinality
Limits
Cardinality limits can also express participation constraints
Number on line represents how many times the entity can
participate in the relationship
Database System Concepts - 6th Edition 7.25 ©Silberschatz, Korth and Sudarshan
Roles
Database System Concepts - 6th Edition 7.26 ©Silberschatz, Korth and Sudarshan
The picture can't be display ed.
Database System Concepts - 6th Edition 7.28 ©Silberschatz, Korth and Sudarshan
Weak Entity Sets (Cont.)
Database System Concepts - 6th Edition 7.29 ©Silberschatz, Korth and Sudarshan
Weak Entity Sets (Cont.)
Note: the primary key of the strong entity set is not explicitly
stored with the weak entity set,
it is implicit in the identifying relationship.
If course_id were explicitly stored, section could be made a
strong entity
but then there is an implicit relationship defined by the
attribute course_id common to course and section
and the implicit relationship duplicates the explicit
relationship between section and course
Database System Concepts - 6th Edition 7.30 ©Silberschatz, Korth and Sudarshan
E-R Diagram for a University Enterprise
Database System Concepts - 6th Edition 7.31 ©Silberschatz, Korth and Sudarshan
Reduction to Relational Schemas
Database System Concepts - 6th Edition 7.32 ©Silberschatz, Korth and Sudarshan
Representing Entity Sets With Simple
Attributes
Database System Concepts - 6th Edition 7.33 ©Silberschatz, Korth and Sudarshan
Representing Relationship Sets
Database System Concepts - 6th Edition 7.34 ©Silberschatz, Korth and Sudarshan
Redundancy of Schemas
Many-to-one and one-to-many relationship sets that are total on
the many-side can be represented by adding an extra attribute
to the “many” side, containing the primary key of the “one” side
Example: Instead of creating a schema for relationship set
inst_dept, add an attribute dept_name to the schema arising
from entity set instructor
Database System Concepts - 6th Edition 7.35 ©Silberschatz, Korth and Sudarshan
Redundancy of Schemas (Cont.)
Database System Concepts - 6th Edition 7.36 ©Silberschatz, Korth and Sudarshan
Composite and Multivalued Attributes
Database System Concepts - 6th Edition 7.38 ©Silberschatz, Korth and Sudarshan
Multivalued Attributes (Cont.)
Special case:entity time_slot has only one attribute other than the
primary-key attribute, and that attribute is multivalued
Optimization: Don’t create the relation corresponding to the entity,
just create the one corresponding to the multivalued attribute
time_slot(time_slot_id, day, start_time, end_time)
Caveat: time_slot attribute of section (from sec_time_slot) cannot
be a foreign key due to this optimization
Database System Concepts - 6th Edition 7.39 ©Silberschatz, Korth and Sudarshan
Extended ER Features
Specialization/Generalization
Aggregation (see book for details)
Database System Concepts - 6th Edition 7.40 ©Silberschatz, Korth and Sudarshan
Extended E-R Features: Specialization
Database System Concepts - 6th Edition 7.41 ©Silberschatz, Korth and Sudarshan
Specialization Example
Database System Concepts - 6th Edition 7.42 ©Silberschatz, Korth and Sudarshan
Design Constraints on a
Specialization/Generalization
Constraint on which entities can be members of a given lower-
level entity set.
condition-defined
Example: all customers over 65 years are members of
senior-citizen entity set; senior-citizen ISA person.
user-defined
Constraint on whether or not entities may belong to more than one
lower-level entity set within a single generalization.
Disjoint
an entity can belong to only one lower-level entity set
Noted in E-R diagram by having multiple lower-level entity
sets link to the same triangle
Overlapping
an entity can belong to more than one lower-level entity set
Database System Concepts - 6th Edition 7.43 ©Silberschatz, Korth and Sudarshan
Design Constraints on a
Specialization/Generalization (Cont.)
Completeness constraint -- specifies whether or not
an entity in the higher-level entity set must belong to at
least one of the lower-level entity sets within a
generalization.
total : an entity must belong to one of the lower-level
entity sets
partial: an entity need not belong to one of the
lower-level entity sets
Database System Concepts - 6th Edition 7.44 ©Silberschatz, Korth and Sudarshan
Representing Specialization via
Schemas
Method 1:
Form a schema for the higher-level entity
Form a schema for each lower-level entity set, include
primary key of higher-level entity set and local attributes
schema attributes
person ID, name, street, city
student ID, tot_cred
employee ID, salary
Drawback: getting information about, an employee requires
accessing two relations, the one corresponding to the low-
level schema and the one corresponding to the high-level
schema
Database System Concepts - 6th Edition 7.45 ©Silberschatz, Korth and Sudarshan
Representing Specialization as Schemas
(Cont.)
Method 2:
Form a schema for each entity set with all local and inherited
attributes
schema attributes
person ID, name, street, city
student ID, name, street, city, tot_cred
employee ID, name, street, city, salary
If specialization is total, the schema for the generalized entity set
(person) not required to store information
Can be defined as a “view” relation containing union of
specialization relations
But explicit schema may still be needed for foreign key
constraints
Drawback: name, street and city may be stored redundantly for
people who are both students and employees
Database System Concepts - 6th Edition 7.46 ©Silberschatz, Korth and Sudarshan
The picture can't be display ed.
Database System Concepts - 6th Edition 7.48 ©Silberschatz, Korth and Sudarshan
Symbols Used in E-R Notation (Cont.)
Database System Concepts - 6th Edition 7.49 ©Silberschatz, Korth and Sudarshan
Alternative ER Notations
Chen, IDE1FX, …
Database System Concepts - 6th Edition 7.50 ©Silberschatz, Korth and Sudarshan
Alternative ER Notations
Database System Concepts - 6th Edition 7.51 ©Silberschatz, Korth and Sudarshan