Week 3_Reduction of ER Model to Tables
Week 3_Reduction of ER Model to Tables
Database System Concepts - 7th Edition 6.2 ©Silberschatz, Korth and Sudarshan
Reduction to Relation Schemas
Database System Concepts - 7th Edition 6.3 ©Silberschatz, Korth and Sudarshan
Representing Entity Sets
▪ A weak entity set becomes a table that includes a column for the primary
key of the identifying strong entity set
section ( course_id, sec_id, sem, year )
▪ Example
Database System Concepts - 7th Edition 6.4 ©Silberschatz, Korth and Sudarshan
Representation of Entity Sets with Composite Attributes
Database System Concepts - 7th Edition 6.5 ©Silberschatz, Korth and Sudarshan
Representation of Entity Sets with Multivalued Attributes
Database System Concepts - 7th Edition 6.6 ©Silberschatz, Korth and Sudarshan
Representing Relationship Sets
Database System Concepts - 7th Edition 6.7 ©Silberschatz, Korth and Sudarshan
Redundancy of Schemas
Database System Concepts - 7th Edition 6.8 ©Silberschatz, Korth and Sudarshan
Redundancy of Schemas (Cont.)
▪ For one-to-one relationship sets, either side can be chosen to act as the
“many” side
• That is, an extra attribute can be added to either of the tables
corresponding to the two entity sets
Database System Concepts - 7th Edition 6.9 ©Silberschatz, Korth and Sudarshan
Redundancy of Schemas (Cont.)
Database System Concepts - 7th Edition 6.10 ©Silberschatz, Korth and Sudarshan
Extended E-R Features
Database System Concepts - 7th Edition 6.11 ©Silberschatz, Korth and Sudarshan
Specialization
Database System Concepts - 7th Edition 6.12 ©Silberschatz, Korth and Sudarshan
Specialization Example
▪ Overlapping – employee and student
▪ Disjoint – instructor and secretary
▪ Total and partial
Database System Concepts - 7th Edition 6.13 ©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.14 ©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.15 ©Silberschatz, Korth and Sudarshan
Completeness constraint
Database System Concepts - 7th Edition 6.17 ©Silberschatz, Korth and Sudarshan
Completeness constraint (Cont.)
Database System Concepts - 7th Edition 6.18 ©Silberschatz, Korth and Sudarshan
Aggregation
Database System Concepts - 7th Edition 6.19 ©Silberschatz, Korth and Sudarshan
Aggregation (Cont.)
Database System Concepts - 7th Edition 6.20 ©Silberschatz, Korth and Sudarshan
Aggregation (Cont.)
Database System Concepts - 7th Edition 6.21 ©Silberschatz, Korth and Sudarshan
Reduction to Relational Schemas
Database System Concepts - 7th Edition 6.22 ©Silberschatz, Korth and Sudarshan
Design Issues
Database System Concepts - 7th Edition 6.23 ©Silberschatz, Korth and Sudarshan
Design of an E-R Database Schema
▪ The E-R data model gives us much flexibility in designing a database schema to
model a given enterprise
▪ Among the designer’s decisions are:
• Whether to use an attribute or an entity set to represent an object.
• Whether a real-world concept is expressed more accurately by an entity set
or by a relationship set.
• Whether to use a ternary relationship or a pair of binary relationships.
• Whether to use a strong or a weak entity set ; a strong entity set and its
dependent weak entity sets may be regarded as a single “object” in the
database, since weak entities are existence dependent on a strong entity.
• Whether using generalization is appropriate; generalization, or a hierarchy of
ISA relationships, contributes to modularity by allowing common attributes of
similar entity sets to be represented in one place in an E-R diagram.
• Whether using aggregation is appropriate; aggregation groups a part of an E-
R diagram into a single entity set, allowing us to treat the aggregate entity
set as a single unit without concern for the details of its internal structure.
Database System Concepts - 7th Edition 6.24 ©Silberschatz, Korth and Sudarshan
Common Mistakes in E-R Diagrams
Database System Concepts - 7th Edition 6.25 ©Silberschatz, Korth and Sudarshan
Common Mistakes in E-R Diagrams (Cont.)
Database System Concepts - 7th Edition 6.26 ©Silberschatz, Korth and Sudarshan
Entities vs. Attributes
Database System Concepts - 7th Edition 6.27 ©Silberschatz, Korth and Sudarshan
Entities vs. Relationship sets
Database System Concepts - 7th Edition 6.28 ©Silberschatz, Korth and Sudarshan
Summary of Symbols Used in E-R Notation
Database System Concepts - 7th Edition 6.29 ©Silberschatz, Korth and Sudarshan
Symbols Used in E-R Notation (Cont.)
Database System Concepts - 7th Edition 6.30 ©Silberschatz, Korth and Sudarshan
Alternative ER Notations
▪ Chen, IDE1FX, …
Database System Concepts - 7th Edition 6.31 ©Silberschatz, Korth and Sudarshan
Alternative ER Notations
Database System Concepts - 7th Edition 6.32 ©Silberschatz, Korth and Sudarshan
UML
Database System Concepts - 7th Edition 6.33 ©Silberschatz, Korth and Sudarshan
ER vs. UML Class Diagrams
Database System Concepts - 7th Edition 6.34 ©Silberschatz, Korth and Sudarshan
ER vs. UML Class Diagrams
Database System Concepts - 7th Edition 6.35 ©Silberschatz, Korth and Sudarshan
UML Class Diagrams (Cont.)
Database System Concepts - 7th Edition 6.36 ©Silberschatz, Korth and Sudarshan
ER vs. UML Class Diagrams
Database System Concepts - 7th Edition 6.37 ©Silberschatz, Korth and Sudarshan
Design Phases – Step-by-step
Database System Concepts - 7th Edition 6.38 ©Silberschatz, Korth and Sudarshan
Design Phases
▪ The initial phase of database design, is to characterize fully the data needs
of the prospective database users.
▪ The database designer needs to interact extensively with domain experts
and users to carry out this task.
▪ The outcome of this phase is a specification of user requirements.
▪ 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.
Database System Concepts - 7th Edition 6.39 ©Silberschatz, Korth and Sudarshan
Design Phases cont
Database System Concepts - 7th Edition 6.40 ©Silberschatz, Korth and Sudarshan
Design Phases cont
Database System Concepts - 7th Edition 6.41 ©Silberschatz, Korth and Sudarshan
Design Phases cont
Database System Concepts - 7th Edition 6.42 ©Silberschatz, Korth and Sudarshan
APPLY THE CONCEPTS
LEARNED
Database System Concepts - 7th Edition 6.43 ©Silberschatz, Korth and Sudarshan
Database Design for a University Organization
Database System Concepts - 7th Edition 6.44 ©Silberschatz, Korth and Sudarshan
Database Design for a University Organization cont
Database System Concepts - 7th Edition 6.45 ©Silberschatz, Korth and Sudarshan
Entity Sets Designation
Database System Concepts - 7th Edition 6.46 ©Silberschatz, Korth and Sudarshan
Relationship Sets
Database System Concepts - 7th Edition 6.47 ©Silberschatz, Korth and Sudarshan
Exercise
▪ Verify that none of the entity sets has any attribute that is made
redundant by one of the relationship sets.
▪ Verify that all the information (other than constraints) in the relational
schema for the university database has been captured by the above
design, but with several attributes in the relational design replaced by
relationships in the E-R design.
▪ Reduce the E-R model into a relational model
Database System Concepts - 7th Edition 6.48 ©Silberschatz, Korth and Sudarshan
E – R Diagram
Database System Concepts - 7th Edition 6.49 ©Silberschatz, Korth and Sudarshan
EXAMPLE 2
Database System Concepts - 7th Edition 6.50 ©Silberschatz, Korth and Sudarshan
Database Design for a Banking Enterprise
Database System Concepts - 7th Edition 6.51 ©Silberschatz, Korth and Sudarshan
Entity Sets Designation
Database System Concepts - 7th Edition 6.52 ©Silberschatz, Korth and Sudarshan
Entity Sets Designation cont
Database System Concepts - 7th Edition 6.53 ©Silberschatz, Korth and Sudarshan
Relationship Sets Designation
Database System Concepts - 7th Edition 6.54 ©Silberschatz, Korth and Sudarshan
Database System Concepts - 7th Edition 6.55 ©Silberschatz, Korth and Sudarshan
Goals of ER Modeling
Database System Concepts - 7th Edition 6.56 ©Silberschatz, Korth and Sudarshan