Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping.

Slides:



Advertisements
Similar presentations
3/25/2017.
Advertisements

Week 5 Relational Database Design by ER- -to-Relational Mapping.
Relational Database Design Via ER Modelling
Mapping ER to Relational Model
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 7- 1.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- and EER-to-Relational Mapping.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
Database Systems Chapter 7 ITM 354. Chapter Outline ER-to-Relational Schema Mapping Algorithm –Step 1: Mapping of Regular Entity Types –Step 2: Mapping.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping.
Summary of Mapping constructs and constraints
Chapter 7 Relational Database Design by ER- and EER-to-Relational Mapping Copyright © 2004 Pearson Education, Inc.
Database Systems ER and EER to Relational Mapping Toqir Ahmad Rana Database Management Systems 1 Lecture 18.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Chapter 91 ER & EER to Relational Mapping. Chapter 92 ER to Relational Mapping Step 1: For each regular entity type E in the ER schema, create a relation.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to-Relational Mapping.
ER- and EER-to-Relational Mapping
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 7- 1.
Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008
Relational Database Design by ER- and EER-to-Relational Mapping
Chapter 21 B Mapping to ODL Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- to-Relational Mapping.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
Relational Database Design by ER- and EER-to- Relational Mapping
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Normalization.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Relational Database Design by ER to Relational Mapping by Pinar Senkul resources: mostly.
Slide Chapter 7 Relational Database Design by ER- to-Relational Mapping.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Relational Database Design by ER- and EERR-to-Relational Mapping.
Chapter 6 Relational Database Design by ER- and EERR-to-Relational Mapping Copyright © 2004 Pearson Education, Inc.
Relational Database Design by ER- and EER-to-Relational Mapping The main reference of this presentation is the textbook and PPT from : Elmasri & Navathe,
Chapter 5 ER-to- Relational Mapping HUANG XUEHUA.
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
ER/EER to Relational Mapping Chapter 9. STEP 1 ENTITY TYPE E (non weak) -> NEW RELATION T RELATION T: – includes all simple attributes (non composite,
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences The Relational.
ER-TO-RELATIONAL MODEL MAPPING CONTENT SOURCES: ELAMSARI AND NAVATHE, FUNDAMENTALS OF DATABASE MANAGEMENT SYSTEMS.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 9 Relational Database Design by ER- and EERR-to-Relational Mapping Slide 9- 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 7- 1.
ER- Relational Mapping (Based on Chapter 9 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
Introduction to Database Systems
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EER-to-Relational Mapping
Chapter 7 Relational Database Design by ER- and EERR-to-Relational Mapping.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER- to-Relational Mapping.
Databases (CS507) CHAPTER 8
Relational Database Design by ER- and EER-to-Relational Mapping
Chapter 7 Relational Database Design by ER- and EERR-to-Relational Mapping Copyright © 2004 Pearson Education, Inc.
Chapter 7 Relational Database Design by ER- and EERR-to-Relational Mapping Copyright © 2004 Pearson Education, Inc.
Lecture # 21 Chapter # 7 Relational Database Design by ER- and EER-to-Relational Mapping Muhammad Emran Database Systems.
Relational Database Design by ER- and ERR-to-Relational Mapping
Relational Database Design by ER- and EER-to- Relational Mapping
Entity- Relationship (ER) Model
Relational Database Design by ER- and EER-to- Relational Mapping
Enhanced Entity-Relationship (EER) Modeling
ER- and EER-to-Relational
Relational Database Design by ER- and EERR-to-Relational Mapping
Relational Database Design by ER-to-Relational Mapping
9/5/2018.
11/15/2018.
Chapter 8: Mapping a Conceptual Design into a Logical Design
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EER-to- Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
4/11/2019.
Relational Database Design by ER- and EER-to-Relational Mapping
CS4222 Principles of Database System
7/19/2019.
Presentation transcript:

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Relational Database Design by ER- and EER-to- Relational Mapping  Design a relational database schema  Based on a conceptual schema design  Seven-step algorithm to convert the basic ER model constructs into relations  Additional steps for EER model

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm  COMPANY database example: Assume that the mapping will create tables with simple single-valued attributes

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm  Step 1: Mapping of Regular Entity Types: entity relations  For each regular entity type E in the ER schema, create a relation R that includes all the simple attributes of E.  Include only the simple component attributes of a composite attribute. Choose one of the key attributes of E as the primary key for R. If the chosen key of E is a composite, then the set of simple attributes that form it will together form the primary key of R.  If multiple keys were identified for E during the conceptual design, the information describing the attributes that form each additional key is kept in order to specify secondary (unique) keys of relation R. Knowledge about keys is also kept for indexing purposes and other types of analyses.  Each tuple represents an entity instance

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm (cont’d.)  Step 2: Mapping of Weak Entity Types  For each weak entity type W in the ER schema with owner entity type, create a relation R and include all simple attributes of the entity type as attributes of R  Include primary key attribute of owner as foreign key  The primary key of R is the combination of the primary key(s) of the owner(s) and the partial key of the weak entity type W, if any attributes of R

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm (cont’d.)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm (cont’d.)  Step 3: Mapping of Binary 1:1 Relationship Types  For each binary 1:1 relationship type R in the ER schema, identify the relations S and T that correspond to the entity types participating in R  Possible approaches: Foreign key approach Choose one of the relations—S, say—and include as a foreign key in S the primary key of T. It is better to choose an entity type with total participation in R in the role of S. Include all the simple attributes (or simple components of composite attributes) of the 1:1 relationship type R as attributes of S.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm (cont’d.)  Step 3: Mapping of Binary 1:1 Relationship Types  Possible approaches: Foreign key approach Merged relationship approach An alternative mapping of a 1:1 relationship type is to merge the two entity types and the relationship into a single relation. This is possible when both participations are total. Cross-reference or relationship relation approach set up a third relation R for the purpose of cross-referencing the primary keys of the two relations S and T representing the entity types. The relation R is called a relationship relation (or sometimes a lookup table). The drawback is having an extra relation, and requiring an extra join operation when combining related tuples from the tables.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm (cont’d.)  Step 4: Mapping of Binary 1:N Relationship Types  For each regular binary 1:N relationship type R Identify relation that represents participating entity type at N- side of relationship type Include primary key of other entity type as foreign key in S Include simple attributes of 1:N relationship type as attributes of S  Alternative approach Use the relationship relation (cross-reference) option as in the third option for binary 1:1 relationships

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm (cont’d.)  Step 5: Mapping of Binary M:N Relationship Types  For each binary M:N relationship type R Create a new relation S Include primary key of participating entity types as foreign key attributes in S; their combination will form the primary key of S. Include any simple attributes of M:N relationship type

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm (cont’d.)  Step 6: Mapping of Multivalued Attributes  For each multivalued attribute A Create a new relation R Primary key of R is the combination of A and primary key attribute K of the relation that represents the entity type or relationship type that has A as a multivalued attribute If the multivalued attribute is composite, include its simple components

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

ER-to-Relational Mapping Algorithm (cont’d.)  Step 7: Mapping of N-ary Relationship Types  For each n-ary relationship type R Create a new relation S to represent R Include primary keys of participating entity types as foreign keys Include any simple attributes as attributes

Copyright © 2011 Ramez Elmasri and Shamkant Navathe ER-to-Relational Mapping Algorithm (cont’d.)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Discussion and Summary of Mapping for ER Model Constructs

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Discussion and Summary of Mapping for ER Model Constructs (cont’d.)  In a relational schema, relationship types are not represented explicitly  Represented by having two attributes A and B: one a primary key and the other a foreign key

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Mapping of Specialization or Generalization  Step 8: Options for Mapping Specialization or Generalization  Option 8A: Multiple relations—superclass and subclasses Create a relation L for C with attributes Attrs(L) = {k, a1,..., an} and PK(L) = k. Create a relation Li for each subclass Si, 1 ≤ i ≤ m, with the attributes Attrs(Li) = {k} ∪ {attributes of Si} and PK(Li) = k. This option works for any specialization (total or partial, disjoint or overlapping)

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Mapping of Specialization or Generalization  Option 8B: Multiple relations—subclass relations only Subclasses are total (every entity in the superclass must belong to (at least) one of the subclasses). Specialization has disjointedness constraint Create a relation Li for each subclass Si, 1 ≤ i ≤ m, with the attributes Attrs(Li) = {attributes of Si} ∪ {k, a1,..., an} and PK(Li) = k. If the specialization is overlapping, the same entity may be duplicated in several relations.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Mapping of Specialization or Generalization (cont’d.)  Option 8C: Single relation with one type attribute Type or discriminating attribute indicates subclass of tuple. Create a single relation L with attributes Attrs(L) = {k, a1,..., an} ∪ {attributes ofS1} ∪... ∪ {attributes of Sm} ∪ {t} and PK(L) = k. The attribute t is called a type (or discriminating) attribute whose value indicates the subclass to which each tuple belongs, if any. This option works only for a specialization whose subclasses are disjoint, and has the potential for generating many NULL values if many specific attributes exist in the subclasses.

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Mapping of Specialization or Generalization (cont’d.)  Option 8D: Single relation with multiple type attributes Create a single relation schema L with attributes Attrs(L) = {k, a1,..., an} ∪ {attributes ofS1} ∪... ∪ {attributes ofSm} ∪ {t1, t2,..., tm} and PK(L) = k. Each ti, 1 ≤ i ≤ m, is a Boolean type attribute indicating whether a tuple belongs to subclass Si. This option is used for a specialization whose subclasses are overlapping. Will also work for a disjoint specialization

Copyright © 2011 Ramez Elmasri and Shamkant Navathe

Mapping of Shared Subclasses (Multiple Inheritance)  Apply any of the options discussed in step 8 to a shared subclass

Copyright © 2011 Ramez Elmasri and Shamkant Navathe Mapping of Categories (Union Types)  Step 9: Mapping of Union Types (Categories)  A category (or union type) is a subclass of the union of two or more superclasses that can have different keys because they can be of different entity types  Creating a relation to correspond to the category. The keys of the defining classes are different  Specify a new key attribute Surrogate key

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Copyright © 2011 Ramez Elmasri and Shamkant Navathe