ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen1 ER-to-Relational Mapping Principles Specialization/Generalization -Superclass/Subclass Relationship.

Slides:



Advertisements
Similar presentations
Relational Database Design : ER- Mapping
Advertisements

Database Design Using Entity-Relationship Models zMapping E-R models into relations zFour common data structures.
Database Basics Jan. 2010Yangjun Chen ACS Outline: Database Basics Database system architecture Data modeling Entity-relationship model -Entity types.
Mapping ER to Relational Model
Database technology Lecture 4: Mapping of EER model to relations Jose M. Peña
1 Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – EER Model –21th June.
Jan Advanced Data Modeling Subclasses Superclasses Specialization Attribute inheritance Generalization Discriminator Lattice Category EER-to-Relational.
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
Databases and Database Users Sept. 2012Yangjun Chen ACS Outline: Introduction (Chapter 1 – 3 rd, 4 th, 5 th, 6 th ed.) What is a database? The main.
Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Outline: Data modeling using ER-model (Chapter 3 - 3rd, 4th, 5th ed.)
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.
Transforming an ER Model into a Relational Schema  Cs263 Lecture 10.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- and EER-to-Relational Mapping.
Sept ER-to-Relational Mapping Principles ER-to-Relational Mapping And examples.
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.
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
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
Chapter 3 Relational Model Chapter 4 in Textbook.
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
Lecture4: Informal guidelines for good relational design Mapping ERD to Relation Ref. Chapter3 Lecture4 1.
1 DATABASE By Mr. Abdalla A. Shaame.  What is a database?  The main characters of a database system  The basic database design method  The entity-relationship.
Entities and Attributes
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- to-Relational Mapping.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
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)
Mapping from conceptual model (EER-M)
Relational Database Design by ER- and EERR-to-Relational Mapping.
Enhanced Entity-Relationship (EER) Modeling. Slide 4- 2 Chapter Outline EER stands for Enhanced ER or Extended ER EER Model Concepts Includes all modeling.
Chapter 6 Relational Database Design by ER- and EERR-to-Relational Mapping Copyright © 2004 Pearson Education, Inc.
Chapter 17 Logical Database Design for the Relational Model Pearson Education © 2009.
ER/EER to Relational Data Model 1 Database Design.
Relational Database Design by ER- and EER-to-Relational Mapping The main reference of this presentation is the textbook and PPT from : Elmasri & Navathe,
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
advanced data modeling
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences The Relational.
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)
Mapping ER Diagrams to Tables
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.
Translation of EER model into relational model Jose M. Peña
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
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
Chapter -3- Data Modeling Using the Entity-Relationship Model
9/5/2018.
11/15/2018.
Outline: Database Basics
Chapter 8: Mapping a Conceptual Design into a Logical Design
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
Mapping an ERD to a Relational Database
7/19/2019.
Presentation transcript:

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen1 ER-to-Relational Mapping Principles Specialization/Generalization -Superclass/Subclass Relationship Outline: ER-to-Relational Mapping Chapter 9 – 3rd ed. (Chap. 7 – 4 th, 5 th ed.; Chap. 9, 6 th ed.)

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen2 Sec. 9.1, Sec. 4.1 and 4.2. General process 1. Create a relation for each strong entity type 2. Create a relation for each weak entity type include primary key of owner (an FK - foreign key) owner’s PK + partial key becomes PK 3. For each binary 1:1 relationship choose an entity and include the other’s PK in it as an FK. Include any attributes of the relationship 4. For each binary 1:n relationship, choose the n-side entity and include an FK w.r.t the other entity. Include any attributes of the relationship

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen3 5. For each binary M:N relationship, create a relation for the relationship include PKs of both participating entities and any attributes of the relationship PK is the concatenation of the participating entity PKs 6. For each multivalued attribute create a new relation include the PK attributes of the entity type PK is the PK of the entity type and the multivalued attribute 7. For each n-ary relationship, create a relation for the relationship include PKs of all participating entities and any attributes of the relationship PK may be the concatenation of the participating entity PKs

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen4 1. Create a relation for each strong entity type include all simple attributes choose a primary key Suppose we have: course 1N offered in Section no term meeting course no name credit hours description section

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen5 We create a relation for Course - four attributes, course_no is the PK. course 1N offered in Section no term meeting course no name credit hours description section Course Course_nonamecredit_hoursdescription

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen6 2. Create a relation for each weak entity type include primary key of owner (an FK) Owner’s PK + partial key become the PK Suppose we have: course 1N offered in Section no term meeting course no name credit hours description section

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen7 We create a relation for Section course 1N offered in Section no term meeting course no name credit hours description section Section Course_noSection_noTerm PK is {course_no, section_no}. course_no is an FK. meeting is not a simple attribute, so it’s not included.

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen8 3. For each binary 1:1 relationship choose an entity and include the other’s PK in it as an FK. departmentinstructor chair 11 dept_no dname instr_noiname There are two choices here choose department, or choose instructor Which is the better choice?

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen9 Department is the better choice since it must participate in the relationship. departmentinstructor chair 11 dept_no dname instr_noiname Department chairdept_nodname If we choose department then instr_no is included as, of course, an FK. Note that instr_no must have a value.

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen10 4. For each binary 1:n relationship, choose the n-side entity and include an FK w.r.t the other entity. departmentinstructor employs 1N dept_no dname instr_noiname We must choose instructor We end up with: instructor instr_noinamedept_no PK is instr_no dept_no is an FK Note that Step 1 would lead to the instructor relation - we have now augmented instructor with the dept_no attribute.

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen11 5. For each binary M:N relationship, create a relation for the relationship include PKs of both participating entities and any attributes of the relationship PK is the catenation of the participating entities’ PKs studentcourse enroll mn grade Enroll student_noCourse_nograde PK is {student_no, course_no} student_no is a FK course_no is a FK grade is an attribute of Enroll course_no student_no

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen12 6. For each multi-valued attribute create a new relation include the PK attributes of the entity type PK is the PK of the entity type and the multi-valued attribute course 1N offered in Section no term meeting course no name credit hours description section Meeting is a multi-valued attribute

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen13 Create a relation for meeting Section was created because of Step 2 - its PK is {course_no, section_no} meeting Meeting course_nosection_nomeeting PK is {course_no, section_no, meeting}. Meeting is an all-key relation.

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen14 7. For each n-ary relationship, create a relation for the relationship include PKs of all participating entities and any attributes of the relationship PK may be the catenation of the participating entity PKs (depends on cardinalities) semestercourse offers mn room course_no semester_no instructor instr_no p

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen15 We need one relation, offers, with PK of {semester_no, course_no, instr_no} semestercourse offers mn room no course_no semester_no instructor instr_no p Offers course_noinstr_nosemester_noRoom_no

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen16 student graduate undergraduate Return to Entity-Relationship Modeling Consider Section 4.2 on Specialization and Generalization Specialization is the process of defining a set of sub-entities of some entity type. Generalization is the opposite approach/process of determining a supertype based on certain entities having common characteristics. e.g. employees may be paid by the hour or a salary (part vs full-time) e.g. students may be part-time or full-time; graduate or undergraduate these are similar to 1:1 relationships, but they always involve entities of one (super)type these are ‘is-a’ relationships d

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen17 student graduate undergraduate d The arc implies graduate and undergraduate are subtypes of student The bubble and the d imply disjoint subtypes (o - overlap subtypes) A student must be a graduate or undergraduate Participation of supertype may be mandatory or optional Participation of subtype is always mandatory Subtypes may be disjoint or overlapping a predicate (on an attribute) determines the subtype: e.g. attribute Student_class Student_class = ‘graduate’; Student_class = ‘undergraduate’ Student_class Subtype is determined by the student_class attribute

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen18 Mapping to a relational database - Section (Step 8) 4 choices: 1. Create separate relations for the supertype and each of the subtypes. 2. Create relations for the subtypes only - each contains attributes from the supertype. 3. (disjoint subtypes) Create only one relation - includes all of the attributes for the supertype and all for the subtypes, and one discriminator attribute. 4. (overlapping subtypes) Create only one relation - includes all of the attributes for the supertype and all for the subtypes, and one logical discriminator attribute per subtype. PK is always the same - determined from the supertype

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen19 SECRETARYENGINEER d Example for super- & sub-types: choice 1 TECHNICIAN name lname minit fname Ssn bDates Address JobType TypingSpeed TGrade EngType fname, minit, lname, ssn, bdate, address, JobType EMPLOYEE Essn, TypingSpeed SECRETARY Essn, TGrade TECHNICIAN Essn, EngType ENGINEER EMPLOYEE

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen20 CARTRUCK d Example for super- & sub-types: choice 2 VehicleId PriceLicensePlate TNoOfPassengers NoOfAxles VehicleId, LicensePlate, Price, MaxSpeed, NoOfPassenger CAR VehicleId, LicensePlate, Price, NoOfAxles, Tonnage TRUCK MaxSpeed Tonnage Vehicle

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen21 SECRETARYENGINEER d Example for super- & sub-types: choice 3 TECHNICIAN name lname minit fname Ssn bDates Address JobType TypingSpeed TGrade EngType fname, minit, lname, ssn, bdate, address, JobType, TypingSpeed, Tgrade, EngType EMPLOYEE

ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen22 Part Manufacture_PartPurchased_Part o Example for super- & sub-types: choice 4 PartNo Description manufactureDate Supplier PartNo, Desription, MFlag, Drawing, ManufactureDate, BatchNo, Pflag, Supplier, ListPrice Part BatchNo DrawingNo ListPrice