Chapter (7) ER-to-Relational Mapping, and other Relational Languages

Slides:



Advertisements
Similar presentations
3/25/2017.
Advertisements

Week 5 Relational Database Design by ER- -to-Relational Mapping.
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.
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- and EER-to-Relational Mapping.
Relational Database Design by ER-to-Relational Mapping.
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.
ER- Relational Mapping (Based on Chapter 7 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 4)
Database Systems Chapter 7 ITM 354. Chapter Outline ER-to-Relational Schema Mapping Algorithm –Step 1: Mapping of Regular Entity Types –Step 2: Mapping.
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.
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
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.
1 E/R to relational mapping algorithm – overview Mapping algorithm step 1-7 Steen Jensen, autumn 2013.
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.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
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-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)
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.
Chapter 71 The Relational Data Model, Relational Constraints & The Relational Algebra.
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.
Entity Relationship Model
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.
9/5/2018.
Lecture # 13 (After 1st Exam)
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Mapping ER Diagrams to Tables
11/15/2018.
Chapter 8: Mapping a Conceptual Design into a Logical Design
Relational Database Design by ER- and EER-to-Relational Mapping
Initial Design of Entity Types: EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT Gender.
ER-to-Relational Mapping Outline
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.
Mapping an ERD to a Relational Database
Relational Database Design by ER- and EER-to-Relational Mapping
7/19/2019.
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

Chapter (7) ER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual schema developed using the ER models. We will look at the Relational Database Design Using ER-to-Relational Mapping. We outline an algorithm that can map an ER schema into the corresponding relational database schema.

ER-Relational Mapping Algorithm We will use the COMPANY database to walk through the algorithm. Step 1: For each regular (strong) 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 primary key for R. If the chosen key of E is composite, the set of simple attributes that form it will together form the primary key of R. Before we go to the next step, let’s look at one definition, Foreign Key. The conditions for a foreign key specify the constraints between two relations and is used to maintain the consistency among tuples (rows) of the two relation schemas R1 and R2. This constrain is called referential integrity constraints. Now we have to answer this question. What are the conditions for a foreign key?

Foreign Key A set of attributes (FK) in relation schema R1 is a foreign key of R1 that reference relation R2 if it satisfies the following two rules: The attributes in FK have the same domain(s) as the primary key attributes PK of R2; the attributes FK are said to reference or refer to the relation R2. A value of FK in a tuple t1 of the current state r1(R1) either occurs as a value of PK for some tuple t2 in the current state r2(R2) or is null. In the former case, we have t1[FK] = t2[PK], and we say that the tuple t1 references or refers to the tuple t2. R1 is called the referencing relation and R2 is the referenced relation. Example: The department that an employee work is not an attribute in the EMPLOYEE entity. The department number will come from the DEPARTMENT entity. Thus, on every tuples of a relation the Department Number (DNO) is a foreign key to the EMPLOYEE relation. Thus, all DNO (on all tuples) on EMPLOYEE relation must much a value of the primary key of DEPARTMENT. This value can be null only if the Employee does not belong to a department. For more info, see 7.2.4.

Step 2: For each weak entity type W in the ER schema with owner entity type E, create a relation R, and include all simple attributes (or simple components of composite attributes) of W as attributes of R. In addition, include as foreign key attributes of R the primary key attribute(s) of the relation(s) that correspond to the owner entity type(s); this takes care of the identifying relationship type of W. 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. Example: We created the relation DEPENDENT in this step to correspond to the weak entity type DEPENDENT. We include the primary key SSN of the EMPLOYEE relation which corresponds to the owner entity type – as a foreign key attribute of DEPENDENT.

STEP 3: 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. Choose one of the relations—S, say—and include as 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. Example: we map the 1:1 relationship type MANGES by choosing the participating entity type DEPARTMENT to serve in the role of S, because its participation in the MANGES relationship type is total.

STEP 4: For each regular binary 1:N relationship type R, identify the relation S that represents the participating entity type at the N-side of the relationship type. Include as foreign key in S the primary key of the relation T that represents the other entity type participating in R; this 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. Include any simple attributes (or simple components of composite attributes) of the 1:N relationship type as attributes of S. Example: we map the 1:N relationship types WORKS_FOR, CONTROLS, and SUPERVISION. WORKS_FOR has DNUMBER as primary key (foreign), SUPERVISION has a SSN as primary key (foreign), and The CONTROLS relationship has DNUM of PROJECT as its key (also foreign).

STEP 5: For each binary M:N relationship type R, create a new relation S to represent R. Include as foreign key attributes in S the primary keys of the relations that represent the participating entity types; their combination will form the primary key of S. Also include any simple attributes of the M:N relationship type (or simple components of composite attributes) as attributes of S. Notice 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. Example: we map the M:N relationship type WORKS_ON by creating the relation WORKS_ON as given on Figure 7.5. The primary keys of the PROJECT and EMPLOYEE relations are included as foreign keys in WORKS_ON with the new names PNO and ESSN respectively. The HOURS is a new attribute that represents the number of hours.

STEP 6: For each multivalued attribute A, create a new relation R. This 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. The primary key of R is the combination of A and K. If the multivalued attribute is composite, we include its simple components Example: A relation DEPT_LOCATIONS which includes the DLOCATION that represents the multivalued attribute Locations of DEPARTMENT. It also includes DNUMBER as a foreign key that represents the primary key of the DEPARTMENT relation. Note: The primary key of the DEPT_LOCATION is ……………

STEP 7: For each n-ary relationship type R, where n > 2, create a new relation S to represent R. Include as foreign key attributes in S the primary keys of the relations that represent the participating entity types. Also include any simple attributes of the n-ary relationship type (or simple components of composite attributes) as attributes of S. The primary key of S is usually a combination of all the foreign keys that reference the relations representing the participating entity types. However, if the cardinality constraints on any of the entity types E participating in R is 1, then the primary key of S should not include the foreign key attribute that references the relation E’ corresponding to E (see section 4.7). This concludes the mapping procedure. Example: On Figure 9.1, one can see that the relation SUPPLY with primary key {SNAME, PARTNO, PROJECTNAME}.

7.1

Summary of Mapping for Model Constructs and Constraints 7.1