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

Slides:



Advertisements
Similar presentations
Chapter 2: Entity-Relationship Model
Advertisements

Chapter 6: Entity-Relationship Model
Temple University – CIS Dept. CIS616– Principles of Database Systems
Chapter 2: Entity-Relationship Model
Relational Database Design Via ER Modelling
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Huiswerk Lees delen 3.2, 3.3 van hoofdstuk 3. opgaven voor hoofdstuk 2: modelleeropgave 5.
Ver 1,12/09/2012Kode :CCs 111,Sistem basis DataFASILKOM Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions.
Chapter 2: Entity-Relationship Model
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Database Management Systems I Alex Coman, Winter 2006 Entity-Relationship.
Chapter 3: Relational Model
1 Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an E-R Database.
Chapter 2: Entity-Relationship Model
©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.
©Silberschatz, Korth and Sudarshan1.1Database System Concepts Wat gaan wij leren? Data Bases Data modelleren  Hoe kan ik zien wat voor informatiesysteem.
Entity-Relationship Model
Amity School of Engineering & Technology E-R Diagram for a University Enterprise.
Ch 6: ER to Relational Mapping
Notes by Ankur Shukla Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys.
Database System Concepts, 5th Ed. Chapter 6: Entity-Relationship Model.
Database Management System (DBMS)
Converting ER model Into Relational Table
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
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.
Chapter 7 Database Design and The E–R Model. 2 Goals n Facilitate DB design and represent the overall logical structure of the DB. n Definition Entities.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
Chapter 6: Entity-Relationship Model. Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity Sets Extended E-R Features Design of the.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan Chapter 6: Entity-Relationship Model.
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.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model ([S] Chp. 6) Entity Sets Relationship Sets Design Issues.
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Entity Relationship Diagram (2)
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
International Computer Institute, Izmir, Turkey E-R Model Asst.Prof.Dr.İlker Kocabaş UBİ502 at
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
 Design Process  Modeling  Constraints  E-R Diagram  Design Issues  Weak Entity Sets  Extended E-R Features  Design of the Bank Database  Reduction.
Database System Concepts, 5th Ed. Bin Mu at Tongji University Chapter 6: Entity-Relationship Model.
Chapter 6: Entity-Relationship Model. Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity Sets Extended E-R Features Design of the.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CS157A Lecture 4 ER Model 2 Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Database Design Slide 1 Database Design Lecture 7 part 2 Mapping ERD to Tables.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
Chapter 2: Entity-Relationship Model. 3.2 Chapter 2: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts - 6 th Edition Chapter 7: Entity-Relationship Model.
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.
Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 6: Entity-Relationship.
Chapter 2: Entity-Relationship Model
Relational Database Design by ER- and EER-to- Relational Mapping
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Chapter 6: Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Introduction to Database
Session 2 Welcome: The seventh learning sequence
Chapter 6: Entity-Relationship Model
Chapter 6: Entity-Relationship Model
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
Chapter 6: Entity-Relationship Model
Chapter 6: Entity-Relationship Model
Chapter 6: Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Presentation transcript:

Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary key Relationship relation Relationship relation Attributes attributes Attributes attributes We will talk about primary later We will talk about primary later Weak entity set relation Weak entity set relation Attributes attributes Attributes attributes We will talk about primary key later We will talk about primary key later

Representing Entity Sets as Tables A strong entity set reduces to a table with the same attributes. A strong entity set reduces to a table with the same attributes.

Composite Attributes Composite attributes are flattened out by creating a separate attribute for each component attribute Composite attributes are flattened out by creating a separate attribute for each component attribute E.g. given entity set customer with composite attribute name with component attributes first-name and last- name the table corresponding to the entity set has two attributes name.first-name and name.last-name E.g. given entity set customer with composite attribute name with component attributes first-name and last- name the table corresponding to the entity set has two attributes name.first-name and name.last-name

Multivalued Attributes A multivalued attribute M of an entity E is represented by a separate table EM A multivalued attribute M of an entity E is represented by a separate table EM Table EM has attributes corresponding to the primary key of E and an attribute corresponding to multivalued attribute M Table EM has attributes corresponding to the primary key 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) 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 Each value of the multivalued attribute maps to a separate row of the table EM E.g., an employee entity with primary key John and dependents Johnson and Johndotir maps to two rows: (John, Johnson) and (John, Johndotir) E.g., an employee entity with primary key John and dependents Johnson and Johndotir maps to two rows: (John, Johnson) and (John, Johndotir)

Representing Weak Entity Sets A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity set

Representing Relationship Sets as Tables A many-to-many relationship set is represented as a table with columns for the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set. A many-to-many relationship set is represented as a table with columns for the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set. E.g.: table for relationship set borrower E.g.: table for relationship set borrower

Redundancy of Tables Many-to-one and one-to-many relationship sets that are total on the many-side can be represented by adding an extra attribute to the many side, containing the primary key of the one side E.g.: Instead of creating a table for relationship account- branch, add an attribute branch to the entity set account

Redundancy of Tables For one-to-one relationship sets, either side can be chosen to act as the many side For one-to-one relationship sets, either side can be chosen to act as the many side That is, extra attribute can be added to either of the tables corresponding to the two entity sets That is, extra attribute can be added to either of the tables corresponding to the two entity sets If participation is partial on the many side, replacing a table by an extra attribute in the relation corresponding to the many side could result in null values If participation is partial on the many side, replacing a table by an extra attribute in the relation corresponding to the many side could result in null values

Determining Keys from E-R Sets Strong entity set. The primary key of the entity set becomes the primary key of the relation. Strong entity set. The primary key of the entity set becomes the primary key of the relation. Weak entity set. The primary key of the relation consists of the union of the primary key of the strong entity set and the discriminator of the weak entity set. Weak entity set. The primary key of the relation consists of the union of the primary key of the strong entity set and the discriminator of the weak entity set.

Determining Keys from E-R Sets Relationship set. The union of the primary keys of the related entity sets becomes a super key of the relation. Relationship set. The union of the primary keys of the related entity sets becomes a super key of the relation. For binary many-to-one relationship sets, the primary key of the many entity set becomes the relations primary key. Why? For binary many-to-one relationship sets, the primary key of the many entity set becomes the relations primary key. Why? For one-to-one relationship sets, the relations primary key can be that of either entity set. Why? For one-to-one relationship sets, the relations primary key can be that of either entity set. Why? For many-to-many relationship sets, the union of the primary keys becomes the relations primary key. Why? For many-to-many relationship sets, the union of the primary keys becomes the relations primary key. Why?

Representing Specialization as Tables Method 1: Method 1: Form a table for the higher level entity Form a table for the higher level entity Form a table for each lower level entity set, include primary key of higher level entity set and local attributes table table attributes personname, street, city customername, credit-rating employeename, salary Form a table for each lower level entity set, include primary key of higher level entity set and local attributes table table attributes personname, street, city customername, credit-rating employeename, salary Drawback: getting information about, e.g., employee requires accessing two tables Drawback: getting information about, e.g., employee requires accessing two tables

Representing Specialization as Tables Method 2: Method 2: Form a table for each entity set with all local and inherited attributes table table attributes personname, street, city customername, street, city, credit-rating employee name, street, city, salary Form a table for each entity set with all local and inherited attributes table table attributes personname, street, city customername, street, city, credit-rating employee name, street, city, salary If specialization is total, table for generalized entity (person) not required to store information If specialization is total, table for generalized entity (person) not required to store information Can be defined as a view relation containing union of specialization tables Can be defined as a view relation containing union of specialization tables But explicit table may still be needed for foreign key constraints But explicit table may still be needed for foreign key constraints Drawback: street and city may be stored redundantly for persons who are both customers and employees Drawback: street and city may be stored redundantly for persons who are both customers and employees

ER for Banking Enterprise