CH 6
CH 6
Model
Database System Concepts - 7th Edition 6.2 ©Silberschatz, Korth and Sudarshan
Design Phases
Database System Concepts - 7th Edition 6.3 ©Silberschatz, Korth and Sudarshan
Logical versus Physical
Database System Concepts - 7th Edition 6.4 ©Silberschatz, Korth and Sudarshan
Logical Design
Database System Concepts - 7th Edition 6.5 ©Silberschatz, Korth and Sudarshan
Logical Design Alternatives
Database System Concepts - 7th Edition 6.6 ©Silberschatz, Korth and Sudarshan
Design Pitfalls
Database System Concepts - 7th Edition 6.7 ©Silberschatz, Korth and Sudarshan
Design Approaches
Database System Concepts - 7th Edition 6.8 ©Silberschatz, Korth and Sudarshan
Outline of the ER Model
The ER model
Database System Concepts - 7th Edition 6.10 ©Silberschatz, Korth and Sudarshan
Entity Sets
An entity is an object that exists and is distinguishable from other
objects.
Example: specific person, company, event, plant
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
An entity is represented by a set of attributes; i.e., descriptive properties
possessed by all members of an entity set.
Example:
instructor = (ID, name, salary )
course= (course_id, title, credits)
A subset of the attributes form a primary key of the entity set; i.e.,
uniquely identifying each member of the set.
Database System Concepts - 7th Edition 6.11 ©Silberschatz, Korth and Sudarshan
Representing Entity sets in ER Diagram
Database System Concepts - 7th Edition 6.13 ©Silberschatz, Korth and Sudarshan
Relationship Sets
Database System Concepts - 7th Edition 6.14 ©Silberschatz, Korth and Sudarshan
Relationship Sets (Cont.)
Database System Concepts - 7th Edition 6.15 ©Silberschatz, Korth and Sudarshan
Representing Relationship Sets via ER Diagrams
Database System Concepts - 7th Edition 6.16 ©Silberschatz, Korth and Sudarshan
Relationship Sets (Cont.)
Database System Concepts - 7th Edition 6.17 ©Silberschatz, Korth and Sudarshan
Relationship Sets with Attributes
Database System Concepts - 7th Edition 6.18 ©Silberschatz, Korth and Sudarshan
Roles
Database System Concepts - 7th Edition 6.19 ©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.
Non-binary relationship
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 - 7th Edition 6.20 ©Silberschatz, Korth and Sudarshan
Non-binary Relationship Sets
Database System Concepts - 7th Edition 6.21 ©Silberschatz, Korth and Sudarshan
Attributes
Attribute types:
Simple and composite attributes.
Allow us to divided attributes into subparts (other attributes).
Single-valued and multivalued attributes
Example: multivalued attribute: phone_numbers
Derived attributes
Can be computed from other attributes
Example: age -- can be derived from given date_of_birth
Domain – the set of permitted values for each attribute
Database System Concepts - 7th Edition 6.22 ©Silberschatz, Korth and Sudarshan
Composite Attributes
Database System Concepts - 7th Edition 6.23 ©Silberschatz, Korth and Sudarshan
Representing Complex Attributes in ER Diagram
Database System Concepts - 7th Edition 6.24 ©Silberschatz, Korth and Sudarshan
Mapping Cardinality Constraints
Database System Concepts - 7th Edition 6.25 ©Silberschatz, Korth and Sudarshan
Mapping Cardinalities
Database System Concepts - 7th Edition 6.26 ©Silberschatz, Korth and Sudarshan
Mapping Cardinalities
Database System Concepts - 7th Edition 6.27 ©Silberschatz, Korth and Sudarshan
Cardinality Constraints in ER Diagram
Database System Concepts - 7th Edition 6.28 ©Silberschatz, Korth and Sudarshan
One-to-Many Relationship
Database System Concepts - 7th Edition 6.29 ©Silberschatz, Korth and Sudarshan
Many-to-One Relationships
Database System Concepts - 7th Edition 6.30 ©Silberschatz, Korth and Sudarshan
Many-to-Many Relationship
Database System Concepts - 7th Edition 6.31 ©Silberschatz, Korth and Sudarshan
Total and Partial Participation
Database System Concepts - 7th Edition 6.32 ©Silberschatz, Korth and Sudarshan
Expressing More Complex Constraints
Database System Concepts - 7th Edition 6.33 ©Silberschatz, Korth and Sudarshan
Cardinality Constraints on Ternary Relationship
Database System Concepts - 7th Edition 6.34 ©Silberschatz, Korth and Sudarshan
Ternary Relationship (Cont.)
If there is more than one arrow, there are two ways of defining the
meaning.
For example, a ternary relationship R between A, B and C with
arrows to B and C could mean
1. Each A entity is associated with a unique entity
from B
and C or
2. Each pair of entities from (A, B) is associated with a
unique C entity, and each pair (A, C) is associated
with a unique B
Each alternative has been used in different formalisms
To avoid confusion, we outlaw more than one arrow
Database System Concepts - 7th Edition 6.35 ©Silberschatz, Korth and Sudarshan
Primary Keys in ER model
Primary keys provide a way to specify how entities and relations are
distinguished. We will consider:
Entity sets
Relationship sets.
Weak entity sets
Database System Concepts - 7th Edition 6.36 ©Silberschatz, Korth and Sudarshan
Primary key for Entity Sets
Database System Concepts - 7th Edition 6.37 ©Silberschatz, Korth and Sudarshan
Primary Key for Relationship Sets
Database System Concepts - 7th Edition 6.38 ©Silberschatz, Korth and Sudarshan
Weak Entity Sets
There are some entities that are totally dependent on other entities.
For example, consider the entity sets
employee (ID, name)
children (name, age)
The entity set children is related to the entity set employee. Clearly,
without an employee entity there will not be a children entity.
The primary key of the employee entity set is ID.
A children entity set does not have a primary key. The attribute name
does not uniquely identify a particular child.
A weak entity set is one whose existence is dependent on another
entity set.
Instead of associating a primary key with a weak entity, we use the
identifying entity, along with extra attributes called discriminator to
uniquely identify a weak entity.
Database System Concepts - 7th Edition 6.39 ©Silberschatz, Korth and Sudarshan
University Example of Weak Entity Sets
The section entities are related to course entities and without course
there will not be sections.
A section entity is uniquely identified by a course_id, semester, year,
and sec_id.
The section entities are related to course entities via a relationship set
sec_course
The information in sec_course is redundant, since section already has
an attribute course_id, which identifies the course with which the section
is related.
Database System Concepts - 7th Edition 6.40 ©Silberschatz, Korth and Sudarshan
Weak Entity Sets (Cont.)
Database System Concepts - 7th Edition 6.41 ©Silberschatz, Korth and Sudarshan
Expressing Weak Entity Sets
Database System Concepts - 7th Edition 6.42 ©Silberschatz, Korth and Sudarshan
Redundant Attributes
Database System Concepts - 7th Edition 6.43 ©Silberschatz, Korth and Sudarshan
E-R Diagram for a University Enterprise
Database System Concepts - 7th Edition 6.44 ©Silberschatz, Korth and Sudarshan
Reduction to Relation Schemas
Reduction to Relation Schemas
Database System Concepts - 7th Edition 6.46 ©Silberschatz, Korth and Sudarshan
Representing Strong Entity Sets
A strong entity set reduces to a schema with the same set of attributes
Example
instructor (ID, name, salary)
student (ID, name, tot_cred)
Database System Concepts - 7th Edition 6.47 ©Silberschatz, Korth and Sudarshan
Representing Weak Entity Sets
A weak entity set becomes a table that includes a column for the primary key
of the identifying strong entity set
Example
Database System Concepts - 7th Edition 6.48 ©Silberschatz, Korth and Sudarshan
Representation of Composite Attributes
Database System Concepts - 7th Edition 6.49 ©Silberschatz, Korth and Sudarshan
Multivalued Attributes
by a schema:
inst_phone= ( ID, phone_number )
Each value of the multivalued attribute maps to a separate tuple of
the relation on schema EM
• For example, an instructor entity with primary key 22222 and
phone numbers 456-7890 and 123-4567 maps to two tuples:
• (22222, 456-7890)
• (22222, 123-4567)
Database System Concepts - 7th Edition 6.50 ©Silberschatz, Korth and Sudarshan
Representing Relationship Sets
Corresponding schema:
advisor = (s_id, i_id)
Database System Concepts - 7th Edition 6.51 ©Silberschatz, Korth and Sudarshan
Representing Relationship Sets (Cont.)
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. No schema is created for the
relationship set.
Example:
Database System Concepts - 7th Edition 6.52 ©Silberschatz, Korth and Sudarshan
Representing Relationship Sets (cont.)
Database System Concepts - 7th Edition 6.53 ©Silberschatz, Korth and Sudarshan
Redundancy of Schemas
Database System Concepts - 7th Edition 6.54 ©Silberschatz, Korth and Sudarshan
Extended E-R Features
Specialization
Database System Concepts - 7th Edition 6.56 ©Silberschatz, Korth and Sudarshan
Specialization Example
Overlapping – employee and student
Disjoint – instructor and secretary
Total and partial
Database System Concepts - 7th Edition 6.57 ©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
Database System Concepts - 7th Edition 6.58 ©Silberschatz, Korth and Sudarshan
Representing Specialization as Schemas
(Cont.)
Method 2:
• Form a schema for each entity set with all local and inherited
attributes
Database System Concepts - 7th Edition 6.59 ©Silberschatz, Korth and Sudarshan
Generalization
Database System Concepts - 7th Edition 6.60 ©Silberschatz, Korth and Sudarshan
Completeness constraint
Database System Concepts - 7th Edition 6.61 ©Silberschatz, Korth and Sudarshan
Completeness constraint (Cont.)
Database System Concepts - 7th Edition 6.62 ©Silberschatz, Korth and Sudarshan
Aggregation
Database System Concepts - 7th Edition 6.63 ©Silberschatz, Korth and Sudarshan
Aggregation (Cont.)
Database System Concepts - 7th Edition 6.64 ©Silberschatz, Korth and Sudarshan
Aggregation (Cont.)
Database System Concepts - 7th Edition 6.65 ©Silberschatz, Korth and Sudarshan
Aggregation -- Reduction to Relational Schemas
Database System Concepts - 7th Edition 6.66 ©Silberschatz, Korth and Sudarshan
Design Issues
Entities vs. Attributes
Database System Concepts - 7th Edition 6.68 ©Silberschatz, Korth and Sudarshan
Entities vs. Relationship sets
Database System Concepts - 7th Edition 6.69 ©Silberschatz, Korth and Sudarshan
Binary Vs. Non-Binary Relationships
Database System Concepts - 7th Edition 6.70 ©Silberschatz, Korth and Sudarshan
Converting Non-Binary Relationships to Binary Form
Database System Concepts - 7th Edition 6.71 ©Silberschatz, Korth and Sudarshan
Converting Non-Binary Relationships (Cont.)
Database System Concepts - 7th Edition 6.72 ©Silberschatz, Korth and Sudarshan
E-R Design Decisions
Database System Concepts - 7th Edition 6.73 ©Silberschatz, Korth and Sudarshan
Summary of Symbols Used in E-R Notation
Database System Concepts - 7th Edition 6.74 ©Silberschatz, Korth and Sudarshan
Symbols Used in E-R Notation (Cont.)
Database System Concepts - 7th Edition 6.75 ©Silberschatz, Korth and Sudarshan
Alternative ER Notations
Chen, IDE1FX, …
Database System Concepts - 7th Edition 6.76 ©Silberschatz, Korth and Sudarshan
Alternative ER Notations (Cont.)
Database System Concepts - 7th Edition 6.77 ©Silberschatz, Korth and Sudarshan
Unified Modeling Language (UML)
Database System Concepts - 7th Edition 6.78 ©Silberschatz, Korth and Sudarshan
ER vs. UML Class Diagrams
Database System Concepts - 7th Edition 6.79 ©Silberschatz, Korth and Sudarshan
ER vs. UML Class Diagrams
Database System Concepts - 7th Edition 6.80 ©Silberschatz, Korth and Sudarshan
UML Class Diagrams (Cont.)
Database System Concepts - 7th Edition 6.81 ©Silberschatz, Korth and Sudarshan
ER vs. UML Class Diagrams
Database System Concepts - 7th Edition 6.82 ©Silberschatz, Korth and Sudarshan
Other Aspects of Database Design
Functional Requirements
Data Flow, Workflow
Schema Evolution
Database System Concepts - 7th Edition 6.83 ©Silberschatz, Korth and Sudarshan
End of Chapter 6
Database System Concepts - 7th Edition 6.85 ©Silberschatz, Korth and Sudarshan
Design Phases (Cont.)
Database System Concepts - 7th Edition 6.86 ©Silberschatz, Korth and Sudarshan
Cardinality Constraints on Ternary Relationship
Database System Concepts - 7th Edition 6.87 ©Silberschatz, Korth and Sudarshan