ER- Relational Mapping (Based on Chapter 7 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 4)

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 © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- and EER-to-Relational Mapping.
Mapping of N:M Relationships PERSON-ID TITLE PERSON-NAME DATE-OF-BIRTH PERSON-ID PROJECT-ID HOURS-SPENT PROJECT-ID END-DATE START-DATE E-R Diagram PERSON.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational 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.
Exam 2 Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
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.
Dr. Dang Tran Khanh M.eng. Tran Minh Quang
ER- and EER-to-Relational Mapping
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
1 E/R to relational mapping algorithm – overview Mapping algorithm step 1-7 Steen Jensen, autumn 2013.
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.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Slide Chapter 7 Relational Database Design by ER- to-Relational Mapping.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
1 CS 430 Database Theory Winter 2005 Lecture 15: How to Convert an ER Model to Relations.
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.
Definition and Properties Constraints and Schemas Update
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 © 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)
Transforming ER models to relational schemas
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
Introduction to Database Systems
Lecture (8) 1. Relational Database Design by ER- and EERR- to-Relational Mapping 2.
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.
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.
Relational Database Design by ER- and ERR-to-Relational Mapping
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 EER-to-Relational Mapping
ER- and EER-to-Relational
Relational Database Design by ER- and EERR-to-Relational Mapping
Relational Database Design by ER-to-Relational Mapping
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
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 EER-to- Relational Mapping
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

ER- Relational Mapping (Based on Chapter 7 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 4)

Mapping from ER Model to Relational Model2 Content zRelational Database Design Using ER-to- Relational Mapping yER-to-Relational Mapping Algorithm ySummary of Mapping for Model Constructs and Constraints

Mapping from ER Model to Relational Model3 ER-to-Relational Mapping Algorithm zSTEP 1Strong Entity Types zSTEP 2Weak Entity Types zSTEP 3Binary 1 to 1 Relationship Types zSTEP 4Binary 1 to N Relationship Types zSTEP 5Binary M to N Relationship Types zSTEP 6Multivalued Attributes zSTEP 7n-ary Relationship Types

Mapping from ER Model to Relational Model4 STEP 1 Strong Entity Types Mapping zFor each regular (strong) entity type E in the ER schema, create a relation R that includes all the simple attributes. zInclude only the simple component attributes of a composite attribute.

Mapping from ER Model to Relational Model5 STEP 1 Continued zChoose one of key attributes of E as primary key of R. zIf the chosen key of E is composite, the set of simple attributes that form it will together form the primary key of R.

Mapping from ER Model to Relational Model6 Entity Types Mapping ET B B A BA B

Mapping from ER Model to Relational Model7 Composite Attributes Mapping ET BADE C E D A B

Mapping from ER Model to Relational Model8 STEP 2 Weak Entity Types Mapping zFor each weak entity type W in the ER schema with owner entity type E, ycreate a relation R, and yinclude all simple attributes (simple component of composite attributes) of W as attributes of R.

Mapping from ER Model to Relational Model9 STEP 2 Continued zIn addition, include as foreign key attributes of R the primary key attribute(s) of the owner entity type(s); zThis takes care of the identifying relationship type of W.

Mapping from ER Model to Relational Model10 STEP 2 Continued zThe 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.

Mapping from ER Model to Relational Model11 STEP 2 Continued zIt is common to choose the propagate (CASCADE) option for the referential triggered action on the foreign key in the identifying entity relation of the weak entity type, since a weak entity has an existence dependency on its owner entity. zThis can be used for both ON UPDATE and ON DELETE.

Mapping from ER Model to Relational Model12 Weak entities ET2 B R ET1 A ET2 A ET1 A B

Mapping from ER Model to Relational Model13 STEP 3Binary 1:1 Relationship Types Mapping zFor each binary 1:1 relationship type R in the ER schema, and S and T, the relations that participate in R yChoose one relation, for example S, and yinclude as foreign key in S the primary key of T.

Mapping from ER Model to Relational Model14 1 to 1 Relationship Mapping R 1 ET2 ET1 1 ET2 B ET1 AB A ET2 BA - or -

Mapping from ER Model to Relational Model15 STEP 3Continued zIt is better to choose an entity type with total participating in R as the role of S. zInclude all simple attributes ( or simple component of composite attributes) of the 1:1 relationship type R as attributes of S.

Mapping from ER Model to Relational Model16 1 to 1 relationship R 1 ET2 ET1 1 A ET2 BA

Mapping from ER Model to Relational Model17 STEP 4Binary 1:N Relationship Types Mapping zFor each regular binary 1:N relationship type R, identify the relations S that represents the participating entity type at the N-side of the relationship type.

Mapping from ER Model to Relational Model18 STEP 4Continued zInclude as foreign key in S the primary key of T that represents the other entity type (the 1-side) participating in R; zthis is because each entity instance on the N-side is related to at most one entity instance on the 1-side of the relationship type.

Mapping from ER Model to Relational Model19 STEP 4Continued zInclude any simple attributes (or simple component of composite attributes) of the 1:N relationship type as attributes of S.

Mapping from ER Model to Relational Model20 1 to n Relationship Mapping R 1 ET2 ET1 n A ET2 BA B ET1 A NO

Mapping from ER Model to Relational Model21 STEP 5Binary M to N Relationship Types zFor each binary M:N relationship type R, create a new relation S to represent R. zInclude as a foreign key attributes in S the primary keys of the relations that participates in R; their combination will form the primary key of S.

Mapping from ER Model to Relational Model22 STEP 5Binary M to N Relationship Types zAlso include any simple attributes of the M:N relationship type (or simple component of composite attributes) as attributes of S.

Mapping from ER Model to Relational Model23 M to N Relationship Mapping R n ET2 ET1 n ET2 B ET1 A NO ET2 B ET1 A NO ET2 B ET1 A R AB

Mapping from ER Model to Relational Model24 STEP 5Binary M to N Relationship Types zNotice that we cannot represent an M:N relationship type by a single foreign key attribute in one of the participating relations – as we did for 1:1 or 1:N relationship types – because of the M:N cardinality ratio.

Mapping from ER Model to Relational Model25 STEP 5Binary M to N Relationship Types zNotice that we can always map 1:1 or 1:N relationships in a manner similar to M:N relationships.

Mapping from ER Model to Relational Model26 STEP 6Multivalued Attributes zFor each multivalued attribute A, create a new relation R. zThe relation R will include an attribute corresponding to A, plus the primary key attribute K – as a foreign key in R – of the relation that represents the entity type or relationship type that has A as an attribute.

Mapping from ER Model to Relational Model27 STEP 6Multivalued Attributes zThe primary key of R is the combination of A and K. zIf the multivalued attribute is composite, we include its simple components.

Mapping from ER Model to Relational Model28 Multivalued Attributes Mapping F ET-F AF ET A

Mapping from ER Model to Relational Model29 STEP 7n-ary Relationship Types Mapping zFor each n-ary relationship type R, where n>2, create a new relation S to represent R. zInclude as foreign key attributes in S the primary keys of the relations that represent the participating entity types.

Mapping from ER Model to Relational Model30 STEP 7Continued zAlso include any simple attributes of the n-ary relationship type (or simple components of composite attributes) as attributes of S. zThe primary of S is usually a combination of all the foreign keys that reference the relations representing the participating entity types.

Mapping from ER Model to Relational Model31 STEP 7Continued zHowever, if the cardinality constraints on any of entity type E participating in R is 1, then the primary key of S should not include the foreign key attribute that references relation E.

Mapping from ER Model to Relational Model32

Mapping from ER Model to Relational Model33

Mapping from ER Model to Relational Model34

Mapping from ER Model to Relational Model35 Notes on ER-to-Relational Mapping zRelationships in ER are mapped to foreign key attributes. yA single foreign key needed for 1:1 or 1:N relationships yA extra relation with two foreign keys needed for binary M:N relationship. yFor n-ary relationship, n>2, we need an extra relation with n foreign keys.

Mapping from ER Model to Relational Model36 Notes on ER-to-Relational Mapping zEQUIJOIN operations are needed to materialize the relationships by combining related tuples: yA single EQUIJOIN needed to materialize 1:1 or 1:N relationships. yTwo EQUIJOINS needed to materialize binary M:N relationship yN EQUIJOINS needed to materialize the full n-ary relationship.

Mapping from ER Model to Relational Model37 Notes on ER-to-Relational Mapping zPrimary key of weak entity type includes key of owner relation. zPrimary key of relation representing an n- ary relationship determined from the structural participation constraints.

Mapping from ER Model to Relational Model38 Notes on ER-to-Relational Mapping zWe create a separate relation for each multivalued attribute. zThis is because the relational model does not allow multiple values (a list, or a set of values) for an attribute in a single table.

Mapping from ER Model to Relational Model39 Correspondence Between ER and Relational Models ER ModelRelational Model Entity type“Entity” relation 1:1 or 1:N relationship typeForeign key (or “relationship” relation) M:N relationship type“Relationship” relation and two foreign keys N-ary relationship type“Relationship” relation and n foreign keys Simple attributeAttribute Composite attributeSet of simple component attributes Multivalued attributeRelation and foreign keys Value setDomain Key attributePrimary (or secondary) key