CS34311 Translating ER Schema to Relational Model.

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

Conceptual Design using the Entity-Relationship Model
Week 5 Relational Database Design by ER- -to-Relational Mapping.
Relational Database Design Via ER Modelling
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Translating from ER to Relationship Schema Adapted from Juliana Freire.
Murali Mani The Relational Model. Murali Mani Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still.
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
CS34311 The Entity- Relationship Model. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design Conceptual.
CS34311 The Entity- Relationship Model Part II.. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping.
Modeling Your Data Chapter 2. Part II Discussion of the Model: Good Design/ Bad Design?
Murali Mani The Entity- Relationship Model. Murali Mani Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
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,
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
Entity-Relationship modeling Transparencies
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.
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.
Chapters 15 &16 Conceptual and Logical Database Design Methodology.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
The Relational Model1 ER-to-Relational Mapping and Views.
CS 370 Database Systems Lecture 9 The Relational model.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
1 Translating ER Schema to Relational Model Instructor: Mohamed Eltabakh
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.
CS34311 Translating ER Schema to Relational Model.
Software School of Hunan University Database Systems Design Part III : Mapping ER Diagram to Relational Schema.
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
ER-TO-RELATIONAL MODEL MAPPING CONTENT SOURCES: ELAMSARI AND NAVATHE, FUNDAMENTALS OF DATABASE MANAGEMENT SYSTEMS.
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh Part-2.
CS34311 The Entity- Relationship Model Part I.. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
CS34311 The Entity- Relationship Model Part III..
ER- Relational Mapping (Based on Chapter 9 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
Modeling Your Data Chapter 2 cs5421. Part II Discussion of the Model: Good Design/ Bad Design? cs5422.
IE 423 – Design of Decision Support Systems Data modeling and database development.
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.
CS3431: C-Term Translating ER Schema to Relational Model Instructor: Mohamed Eltabakh
CS34311 Translating ER Schema to Relational Model.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
Relational Database Design by ER- and EER-to-Relational Mapping
COP Introduction to Database Structures
Translating ER Schema to Relational Model
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
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.
Translating ER Schema to Relational Model
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Modeling Your Data Chapter 2 cs542
The Entity-Relationship Model
Normalization Murali Mani.
Relational Database Design by ER- and EER-to-Relational Mapping
Normalization cs3431.
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:

CS34311 Translating ER Schema to Relational Model

cs34312 Basic Mapping So Far Simple algorithms covers base case Idea: Each entity type = separate relation Each relationship type = separate relation

cs34313 Simple Algorithm: Example 3 PRIMARY KEY (Part) = PRIMARY KEY (Contains) = FOREIGN KEY Contains (superPart) REFERENCES Part (pNumber) FOREIGN KEY Contains (subPart) REFERENCES Part (pNumber) Part (pName, pNumber) Contains (superPart, subPart, quantity)

cs34314 Next Let’s consider constraints Let’s reduce number of relations

cs34315 Refinement for Simple Mapping Primary Key for R’ is defined as: If the maximum cardinality of any Ei is 1, primary key for R’ = primary key for Ei

cs34316 Simple Algorithm: Example 3 PRIMARY KEY (Part) = PRIMARY KEY (Contains) = FOREIGN KEY Contains (superPart) REFERENCES Part (pNumber) FOREIGN KEY Contains (subPart) REFERENCES Part (pNumber) Part (pName, pNumber) Contains (superPart, subPart, quantity)

cs34317 Decreasing the Number of Relations Technique 1 If the relationship type R contains an entity type, say E, whose maximum cardinality is 1, then R may be represented as attributes of E.

cs34318 Example 1 If the relationship type R contains an entity type, say E, whose maximum cardinality is 1, then R may be represented as attributes of E.

cs34319 Example 1 Student (sNumber, sName, advisor, years) Professor (pNumber, pName) PRIMARY KEY (Student) = PRIMARY KEY (Professor) = FOREIGN KEY Student (advisor) REFERENCES Professor (pNumber) Question: Will Student.advisor attribute ever be NULL ? Answer: No !

cs Example 2 Person (pNumber, pName, dept, years) Dept (dNumber, dName) PRIMARY KEY (Person) = PRIMARY KEY (Dept) = FOREIGN KEY Person (dept) REFERENCES Dept (dNumber) What about NULL attributes ? Dept and years may be null for a person

cs Remember the Simple Algorithm: Example 3 PRIMARY KEY (Part) = PRIMARY KEY (Contains) = FOREIGN KEY Contains (superPart) REFERENCES Part (pNumber) FOREIGN KEY Contains (subPart) REFERENCES Part (pNumber) Part (pName, pNumber) Contains (superPart, subPart, quantity)

cs Example 3 Part (pNumber, pname, superPart, quantity) PRIMARY KEY (Part) = FOREIGN KEY Part (superPart) REFERENCES Part (pNumber) Note: superPart indicates the superpart of a part, and it may be null

cs Decreasing the Number of Relations Summary of Technique 1 If the relationship type R contains an entity type, say E, whose maximum cardinality is 1, then R may be represented as attributes of E. If cardinality of E is (1, 1), then no “new nulls” added If cardinality of E is (0, 1) then may add “new nulls”

cs Decreasing the number of Relations Technique 2 If relationship type R between E1 and E2 is one-to-one [1:1], and the cardinality of E1 or of E2 is (1, 1), then we can combine everything into 1 relation

cs Decreasing the number of Relations Technique 2 - Method Details Let us assume the cardinality of E1 in R is (1, 1). Then we create one relation for entity E2 And, we move all attributes of E1 and for R to be attributes of E2.

cs Example 1 Student-BIG (sNumber, sName, pNumber, pName, years) PRIMARY KEY (Student) = CANDIDATE KEY (Student) = Note: pNumber, pName, and years can be null for students with no advisor

cs Example 2 Student (sNumber, sName, pNumber, pName, years) PRIMARY KEY (Student) = CANDIDATE KEY (Student) = Note: pNumber cannot be null for any student.

cs Decreasing the Number of Relations Technique 2 If relationship type R between E1 and E2 is one-to-one [1:1], and the cardinality of E1 or of E2 is (1, 1), then we can combine everything into 1 relation Not always recommended! Thus use with care ! While very compact, semantically may not be clearest choice !

cs ER Model: Complex Attributes Composite Attribute: address Student sNamesumer sAge statestreet address city

cs Mapping details Composite attribute in ER Include an attribute for every component of the composite attribute.

cs ER Model: Complex Attributes Multivalued Attribute: major

cs Mapping details Multi-valued attribute in ER We need a separate relation for any multi-valued attribute. Identify appropriate attributes, keys and foreign key constraints.

cs Other details Composite attribute in ER Include an attribute for every component of the composite attribute. Multi-valued attribute in ER We need a separate relation for any multi-valued attribute. Identify appropriate attributes, keys and foreign key constraints.

cs Example: Composite and Multi-valued attributes in ER Student (sNumber, sName, sAge, street, city, state) PRIMARY KEY (Student) = StudentMajor (sNumber, major) PRIMARY KEY (StudentMajor) = FOREIGN KEY StudentMajor (sNumber) REFERENCES Student (sNumber)

cs Summary Simple algorithms covers base case Refinements : Reduce number of relations Refinements: Consider constraints (not NULL) Consider other ER constructs like complex and multi-valued attributes