ER to Relational Mapping Strong Entity Relation: ssno name salary employee Employee(ssno name salary) Key : ssno.

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

Database Design The process of finding user requirement
Conceptual Design using the Entity-Relationship Model
Relational Database Design Via ER Modelling
Prof. Sin-Min Lee Department of Computer Science
ER Modeling Case Studies
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
© Shamkant B. Navathe CC. © Shamkant B. Navathe CC Chapter 4 - Part I Enhanced Entity-Relationship and UML Modeling Copyright © 2004 Ramez Elmasri and.
The Relational Model System Development Life Cycle Normalisation
Relational Model Naveen Ashish Calit2 & Information and Computer Science Department University of California at Irvine.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4- 1.
1 Announcement Recitation time  Before midterm: 6-7pm, by Earl Wagner  After midterm: 5-6pm, by Yi Qiao Newsgroup safe to subscribe  Will not cause.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
1 Enhanced Entity Relationship Modelling EER Model Concepts Includes all basic ER modeling concepts Additional concepts: subclasses/superclasses specialization/generalization.
Database Design & ER Diagrams
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Relational Model Prof. Sharad Mehrotra Information and Computer Science Department University of California at Irvine Chapter 3 and 6 from SKS Chapter.
Enhanced Entity-Relationship and UML Modeling. Enhanced-ER (EER) Model Concepts Includes all modeling concepts of basic ER Additional concepts: subclasses/superclasses,
Ch 6: ER to Relational Mapping
ER Modeling Case Studies
The Entity-Relationship Model. 421B: Database Systems - ER Model 2 Overview of Database Design q Conceptual Design -- A first model of the real world.
Data Modeling Using the Entity-Relationship Model
1 Web-Enabled Decision Support Systems Entity-Relationship Modeling Prof. Name Position (123) University Name.
Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.
Entities and Attributes
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Page 1 Topic 3 ER Model Chapter 14 of the date’s book Chapter 3 and 4 of Elmasri’s book CPS510 Database Systems Abdolreza Abhari School of Computer Science.
ER to Relational Translation COMSATS INSTITUTE OF INFORMATION TECHNOLOGY, VEHARI.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
© Shamkant B. Navathe CC. © Shamkant B. Navathe CC Chapter 4 - Part I Enhanced Entity-Relationship and UML Modeling Copyright © 2004 Ramez Elmasri and.
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 4 Mapping an ER model to tables © Akhilesh Bajaj,
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
Entity Relationship Diagram (2)
1 Conceptual Design using the Entity- Relationship Model.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Enhanced Entity-Relationship (EER) Modeling. Slide 4- 2 Chapter Outline EER stands for Enhanced ER or Extended ER EER Model Concepts Includes all modeling.
Weak Entity Sets A weak entity is an entity that cannot exist in a database unless another type of entity also exists in that database. Weak entity meets.
ICOM 5016 – Introduction to Database Systems Lecture 5 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Data Modelling Using Entity-Relationship (ER) Model
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
Software School of Hunan University Database Systems Design Part III : Mapping ER Diagram to Relational Schema.
Keys for Relationship Sets The combination of primary keys of the participating entity sets forms a super key of a relationship set. – (customer-id, account-number)
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
Topic 4 - Part I Enhanced Entity-Relationship and UML Modeling
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 9 Relational Database Design by ER- and EERR-to-Relational Mapping Slide 9- 1.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Enhanced Entity-Relationship and UML Modeling. 2.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
ER Diagrams and Relational Model CS 174a (Winter 2015)
COP Introduction to Database Structures
Databases (CS507) CHAPTER 7.
Enhanced Entity-Relationship (EER) Model
Enhanced Entity-Relationship and Object Modeling Objectives
© Shamkant B. Navathe CC.
The Enhanced Entity- Relationship (EER) Model
Session 2 Welcome: The sixth learning sequence
Enhanced Entity-Relationship (EER) Modeling
Database EER.
© Shamkant B. Navathe CC.
© Shamkant B. Navathe CC.
Relational Database Design by ER- and EERR-to-Relational Mapping
Database EER.
ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
© Shamkant B. Navathe CC.
Enhanced Entity-Relationship (EER) Modeling
Relational Database Design by ER- and EER-to-Relational Mapping
Presentation transcript:

ER to Relational Mapping Strong Entity Relation: ssno name salary employee Employee(ssno name salary) Key : ssno

Weak EntityRelation : acct# customer balance transaction(acct#,trans#, amount ) account log transaction trans# amount Key: acct# trans# IND: transactional[acct#] account[acct#] ER to Relational Mapping

ssno name salary Relation : works_on(ssno,proj#,startdate) Key: ssno,proj# employee Works on project Startdate M N projprojmgr ER to Relational Mapping ]employee[]workson[ ]#project[]#workson[ ssno proj   Ind:

ssno name salary Relation : works_on(ssno,proj#,startdate) Key: ssno Ind : workson[proj#] project[proj#] workson[ssno] employee[ssno] employee Works on project Startdate M 1 projprojmgr Employee works on atmost 1 project ER to Relational Mapping

ssno name salary Relation : works_on(ssno,proj#,startdate) Key: ssno,proj# Ind : workson[proj#] project[proj#] workson[ssno] employee[ssno] employee[ssno] workson[ssno] employee Works on project Startdate N projprojmgr M Each employ must work on a project ER to Relational Mapping

ssno name salary Relation : worksonusing(ssno,proj#,toolid, startdate) Key : ssno,toolid IND : worksonusing[proj#] project[proj#] worksonusing[ssno] employee[ssno] worksonusing[toolid] tools[toolid] employee[ssno] worksonusing[ssno] employee Workson using project tools startdate toolid toolspecs M 1 N Proj#projmgr Each employee must work on a proj using a tool. Employee uses a given tool works on a single proj ER to Relational Mapping

ssno name salaryRelation: staff(ssno, name, salary, position) faculty(ssno, name, salary, rank) student_assistant(ssno, name, salary, percentage_time) Key: ssno for all the relations cannot use if partial:cannot represent employees who are neither staff, nor faculty, not student assistants! Cannot use if overlap:if staff could also be a student assistant, then redundancy requires a union to construct list of all employees d staff faculty Student assistant employee If no overlap, and total participation ER to Relational Mapping

ssno name salary Relation: employee(ssno, name, salary, jobtype, position, rank, percentage-time) Key : ssno job type can be used to specify whether anemployee is a staff, a faculty, or a student assistant a lot of null values will be used. If an employee does not belong to any subclass, use null value for job type cannot be used if overlap total participation can be represented by preventing null in jobtype does not require union to construct the list of employees d staff faculty Student assistant employee position rank Percenttage time If no overlap, participation can be partial ER to Relational Mapping

ssno name salary Relation: employee (ssno, name, salary) staff(ssno, position) faculty(ssno, rank) student_assistant(ssno, percentage_time) Key : ssno for all the relations IND staff[ssno] employee[ssno] faculty[ssno]employee[ssno] student_assistant[ssno] employee[ssno] cannot represent total constraint o staff faculty Student assistant employee position rank Percenttage time If overlapping ER to Relational Mapping

ssno name salaryRelation: employee(ssno, name, salary, Isstaff, position, Isfaculty, rank, Isstudentassistant, percentage-time) Key : ssno Isstaff, Isfaculty, Isstudent_assistant are boolean values which are either true or false. The relation will contain lot of null values cannot represent total constraint. o staff faculty Student assistant employee position rank Percenttage time another mechanism if overlapping ER to Relational Mapping

 ER Diagrams can be mapped to relational model (except sometimes total participation in a superclass/ subclass relationship is difficult to model)  Recall that at times during the design cycle we wish to do the reverse-- - that is, map relational schema to ER model.  Can this always be done ?  So far the mapping to be correct, we should be able to represent the constraints over a relational schema in the ER model.  Constraints in relational schema -- functional dependencies, inclusion dependencies.  Constraints in ER model: key constraints, cardinality constraints, participation constraints.  Can we model fds and INDs using the constraints in ER model? ER to Relational Mapping

Example  Consider we wish to build a catalog with three fields: street, city, zip  So least we need to do is create an entity with the three attributes: - street city uniquely determines zip -zip uniquely determines city  This can be modelled using the following two FDs in the relational model: -street city zip -zip city  Can the same be modelled in ER using the set of constraints present? ER to Relational Mapping

Example streetcityzip Assume we create a single entity with the three attributes. The only constraints that can be applied are the key constraints {street, city} and {street, zip} are keys. This however, does not prevent presence of two catalog objects: (kirby, champaign, 61801) (florida, urbana, 61801) which should be prevented since zip uniquely determines a city catalog ER to Relational Mapping

Example streetzip code Lets try creating an entity for each attribute and a relationship involving each entity. We can now use cardinality constraints to get the required constraints? Notice that street city uniquely determine zip, so relationship is functional wrt zip. Similarly, street zip uniquely determine city, so relationship is functional wrt city. But how can we model a constraint zip determines the city which involves only two entities using a ternary relation? This shema will also not prevent the catalog objects: (kirby, champaign, 61801) (florida, urbana, 61801) which should be prevented since a zip uniquely determines a city !! street catalog zip city n 1 1 ER to Relational Mapping

Example Will this do? No! since city-of may be an empty relationship and will thus not prevent (kirby, champaign, 61801) (florida, urbana, 61801) which should be prevented since a zip uniquely determines a city!! Actually, it can be formally shown that no ER schema can be used to represent the constraints in this example (you should try other possibilities at home to convince yourself) street catalog zip city n 1 1 cityof n 1 streetZip code ER to Relational Mapping

 Conceptual Modelling -- ER diagrams  ER schema transformed to relational schema (ER to relational mapping).  Add additional constraints at this stage to reflect real world.  Resulting relational schema normalized to generate a good schema (schema normalization process) - avoid redundancy - avoid anomalies - semantically equivalent to the original schema  Schema is tested example databases to evaluate its quality  Correctness results analyzed and corrections to schema are made  Corrections may be translated back to conceptual model to keep the conceptual description of data consistent (relations to ER mapping).  We have seen the ER to relation mapping. We next study normalization process. ER to Relational Mapping