Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.

Slides:



Advertisements
Similar presentations
Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Advertisements

Week 5 Relational Database Design by ER- -to-Relational Mapping.
Relational Database Design Via ER Modelling
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.
Chapter 6 Methodology Logical Database Design for the Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Information Resources Management February 13, 2001.
Methodology Logical Database Design for the Relational Model
Mapping from E-R Model to Relational Model Yong Choi School of Business CSUB.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Reduction of an E-R Schema to Tables A database which conforms to an E-R diagram can be represented.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Mapping ERM to relational database
Ch 6: ER to Relational Mapping
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 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.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Mapping from Data Model (ERD) to Relational Model Yong Choi School of Business CSUB.
DATA MODELING AND DATABASE DESIGN
Chapter 5 Entity–Relationship Modeling
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- to-Relational Mapping.
Mapping from Data Model (ERD) to Relational Model
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
1 E/R to relational mapping algorithm – overview Mapping algorithm step 1-7 Steen Jensen, autumn 2013.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
1 Session 2 Welcome: The seventh learning sequence “ Reduction of an EER schema to tables“ Recap : In the previous learning sequence, we discussed the.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 4 Mapping an ER model to tables © Akhilesh Bajaj,
IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5.
CS 370 Database Systems Lecture 9 The Relational model.
Database Design – Lecture 5 Conceptual Data Modeling – adding attributes.
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.
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
1 Translating ER Schema to Relational Model Instructor: Mohamed Eltabakh
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Slide Chapter 7 Relational Database Design by ER- to-Relational Mapping.
1 Chapter 17 Methodology - Local Logical Database Design.
1 CS 430 Database Theory Winter 2005 Lecture 15: How to Convert an ER Model to Relations.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
CS263 Lecture 5: Logical Database Design Can express the structure of a relation by a Tuple, a shorthand notation Name of the relation is followed (in.
Database Design – Lecture 6 Moving to a Logical Model.
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,
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Database Design – Lecture 7
Lecture4: Informal guidelines for good relational design Mapping ERD to Relation Prepared by L. Nouf Almujally Ref. Chapter3 Lecture4 1.
Lecture (8) 1. Relational Database Design by ER- and EERR- to-Relational Mapping 2.
Relational Database Design by ER- and EER-to-Relational Mapping
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
 1 Chapter 9 Chapter 9 Relational Database Design by ER- to-Relational Mapping.
Chapter 4: Part B Logical Database Design and the Relational Model
Tables and Their Characteristics
Database Design – Lecture 4
Relational Database Design by ER- and EER-to-Relational Mapping
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.
Chapter 4+17 The Relational Model Pearson Education © 2014.
Relational Database Design by ER- and EER-to-Relational Mapping
Session 2 Welcome: The seventh learning sequence
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Systems Instructor Name: Lecture-11.
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EER-to- Relational Mapping
Mapping an ERD to a Relational Database
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:

Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables

Database Design Slide 2 Conversion to Tables  To implement the database in relational DBMS, ERD must be translated to tables –different strategies exist, resulting different tables. –general rules are  The tables should accurately represent the information modeled in the ERD.  choose strategies that result in less redundancy, and fewer null values.

Database Design Slide 3 Conversion of Entities  A (strong) entity set reduces to a table with the same attributes and PK. –If composite attributes exist, only their component simple attributes are needed. –Derived attributes are usually omitted. –Usually NOT including multi_valued attributes either – every multi-valued attribute is put in a separate table.

Database Design Slide 4 Conversion of Multi_valued Attributes  A multivalued attribute M of an entity E is represented by a separate table EM –Table EM has attributes corresponding to the primary key EPK of E and an attribute corresponding to multivalued attribute M. –E.g. Multivalued attribute dependent-names of employee is represented by a table employee-dependent-names(employee-id, dname) –Each value of the multivalued attribute maps to a separate row of the table EM –The PK of table EM may be (EPK, M) or M. –EPK is a FK of EM.

Database Design Slide 5 Conversion of Weak Entities  A weak entity set becomes a table that includes the primary key of the owner entity. The primary key consists of the PK of the owner entity, possibly together with some attributes of the weak entity. Example: Employee has Dependents Dependents(employeeNo, dependentName,…) 1 M

Database Design Slide 6 Conversion of Relationships  Let R be the relationship set involving multiple entities. Let A 1,...,A m be the primary key attributes of the participating entities. Let B 1,..., B n be the attributes of the relationship set. Then the relationship R can be represented by the relation R(A 1,...,A m,B 1,..., B n )  This is a general rule for converting relationships.  The primary key should be chosen from A 1,...,A m according to situation.  A 1,...,A m are foreign keys. . For binary 1:M or 1:1 relationships, the conversions can be (better) done as shown later.

Database Design Slide 7 Conversion of Binary Relationships  Many-to-many binary relationship set –create a table with columns for the PKs of the two participating entity sets, and any descriptive attributes of the relationship set. The PK consists of the PKs of the two entities. The PKs of the two entities also serve as foreign keys referencing the entities.  One-to-many binary relationship sets –Instead of using a separate table for the relationship, just modify the tables for the two entities:  add the PK of the one side to the many side. It also serves as a FK of the many side.  attributes of the relationship also go to the many-side. –if optional on the many-side, can result in null values.

Database Design Slide 8 Conversion of Binary Relationships  One-to-one relationship sets –mandatory participation on both sides  add the PK attributes of one side, and attributes of the relationship, to the other side. –mandatory on one side  add the PK attributes of the optional side, and attributes of the relationship, to the mandatory side. –Optional on both sides  choose one side and add its PK, and attributes of the relationship, to the other side.  May have null values. Maybe using a separate relation for the relationship is better.

Database Design Slide 9 1:1 Unary Relationships  Follow rules for 1:1 binary relationship. –mandatory participation on both sides: single relation with two copies of the primary key (one needs to be renamed), plus attributes of the relationship. –mandatory participation on only one side: option to create a single relation with two copies of the primary key, or create a new relation to represent the relationship. The new relation would only have two attributes (if the relationship does not have attributes itself and the PK of the entity has one attribute), both are copies of the primary key. –optional participation on both sides, again create a new relation as described above.

Database Design Slide 10 Example 1—M:N relationship SUBJECTSTUDENTenrol MN stNo stName date sCode sName Student(stNo, stName) Subject(scode, sName) Enrol(stNo, scode, date) FKs: stNO reference Student(stNo) scode reference Subject(sCode)

Database Design Slide 11 Example 2 – 1:M relationship Staff Subject teach M 1 Staff(stafNo,stafName) Subject(sCode, sName, stafNo, semester) stafNo stafName sCode sName semester

Database Design Slide 12 Example 3 – 1:1 relationship Staff Has Office Staff(stafNo, stafName) StaffOffice(stafNo, oNo, location) 11 stafNo stafName oNo location

Database Design Slide 13 Example 4- 1:1 relationship Staff Has Office StaffOffice(stafNo, stafName) Office(oNo, location, stafNo ) 11 stafNo stafName oNo location

Database Design Slide 14 Example 5 Staff Has Office Staff(stafNo, stafName) Office(oNo, location, staffNo) 11 stafNo stafName oNo location

Database Design Slide 15 Example 6 Staff Has Next-of-Kin stafNo stafName kinName kintelephone Staff(StafNo, stafName) StaffNOK(stafNo, kinName, kintelephone) 1 1

Database Design Slide 16 Example 7- Unary relationship Staff Supervise Staff(stafNo, stafName, supervisorstafNo) M 1 stafNo stafName