Transformation of E/R Diagram to Relation

Slides:



Advertisements
Similar presentations
ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
Advertisements

Logical DB Design: ER to Relational Entity sets to tables. Employees ssn name lot CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY.
Database Management Systems Chapter 3 The Relational Data Model (I) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Databases : Relational Model 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey D. Ullman distributes.
Chapter 4 Notes. Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
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.
--The Entity Relationship Model(1)--1 The Entity Relationship Model.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
From E/R Diagrams to Relations. The Relational Data Model Database Model (E/R) Relational Schema Physical storage Diagrams (E/R) Tables: row names: attributes.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations Source: slides by Jeffrey Ullman.
ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
Relational Databases CPSC 315 – Programming Studio Spring 2013 Project 1, Lecture 2 Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch.
 Entity-relationship models (ERM) Entity-relationship models (ERM)  Simple E-R Diagram Simple E-R Diagram  Weak Entity Weak Entity  Strong Entity.
Normalization Exercise. First Normal Form Second Normal Form.
 Primary keys allow entity sets and relationship sets to be expressed uniformly as relations  E/R diagram  collection of tables  For each entity set.
Mapping E/R to RM, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 Mapping E/R Diagrams to Relational Database Schemas Second Half of Chapter.
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.
CS422 Principles of Database Systems Convert ER Design to Relations Chengyu Sun California State University, Los Angeles.
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
CS422 Principles of Database Systems From ER to Relations Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes.
Announcements Reading for Monday –Appendix A Homework 3 – Due today Project: Steps –Due 10/4 Exam 1 – 10/6.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Entity-Relationship Data Model
Chapter 2: Entity-Relationship Model
Entity Relationship (E-R) Model
CS422 Principles of Database Systems Entity-Relationship Model
COP Introduction to Database Structures
Introduction to Database Systems, CS420
ERwin.
Comp 1100 Entity-Relationship (ER) Model
Chapter 3 Data Modeling Using the Entity-Relationship Model
Entity-Relationship Model
Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
ER Diagram Practical Example
INF385T: Information Modeling — Class 11 Relational Database Design from ER Models Presented November 2 Karen Wickett,
CPSC-310 Database Systems
Payroll Management System
Database Design Determinacy.
Translation of ER-diagram into Relational Schema
CPSC 315 – Programming Studio Fall 2009 Project 1, Lecture 2
CS 174: Server-Side Web Programming February 12 Class Meeting
CPSC-310 Database Systems
CPSC-310 Database Systems
From ER to Relational Model
Order Database – ER Diagram
From E/R Diagrams to Relational Schema
Session 2 Welcome: The seventh learning sequence
name category name price makes Company Product stockprice buys employs
The Entity-Relationship Model
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Chapter 6: Entity-Relationship Model
Functional Dependencies
Lecture 10: The E/R Model III
Chengyu Sun California State University, Los Angeles
Lecture 5: The Relational Data Model
ER to Schema.
CHAPTER 2 - Database Requirements and ER Modeling
Chapter 7: Entity-Relationship Model
The Relational Data Model
Distributed Database Management Systems
MIS2502: Data Analytics Relational Data Modeling 2
Entity-Relationship Data Model
XML, distributed data, replicated data, and Security
CS4222 Principles of Database System
Session 5: Weak Entity Sets and ER Model to Relational ( )
Presentation transcript:

Transformation of E/R Diagram to Relation

Transformation of E/R Diagram to Relation Primary keys allow entity sets and relationship sets to be expressed uniformly as relations E/R diagram  collection of tables For each entity set and each relationship set there is a unique table CSCE 520 11/16/2018

Transformation from E/R to Relation Entity set: becomes a relation with the attributes of the entity set Relationship: becomes a relation with attributes: Key of connected entity sets Attributes of the relationship CSCE 520 11/16/2018

Example E/R Diagram Dog Kennel Owner Breed Name Name License # Boards Age Address Owns Phone Weight Pays Owner Amount Name Phone CSCE 520 11/16/2018

Entity Set to Relation Dog Dog(Name,Breed,Age,Weight) Breed Name Age CSCE 520 11/16/2018

Entity Set to Relation Kennel Owner Name Amount Date Name Address Kennel Pays Owner Phone Pays(Kennel. Name,Owner.Name,Amount,Date) CSCE 520 11/16/2018

Combining Relations: Many-One Name Amount Date Name Address Kennel Pays Owner Phone Favorite Combine relation for entity of “many” side (Owner) with relationship set, i.e., Owner’s-favorite(Name,Phone,FavoriteKennel.Name) CSCE 520 11/16/2018

Combining Relations: Many-Many Name Name Address Kennel Pays Owner Phone Combining Owner with pays: Owner(Kennel.Name,Owner.Name,Phone) CSCE 520 11/16/2018

Many-many Relationship Kennel Name Owner Name Owner Phone White Oak Mary 890-4421 Little Creek Viki 987-4456 Joe 334-2234 Redundancy 11/16/2018 CSCE 520

Weak Entity Sets to Relation Relation for a weak entity set must include attributes for its complete key (including those that belong to other entities) as well as its own, non-key attributes Supporting relationship is redundant and does not yield a relation CSCE 520 11/16/2018

Example: Weak Entity Set Breed Name Name Dog Owns Owner Phone Age Owner(Owner.Name, Phone) Dog(Dog.Name,Owner.Name, Age,Breed) Owns(Dog.Name,Owner.Name1,Owner.Name2) Already in Dog Redundant! Must be the same CSCE 520 11/16/2018

Entity Sets with Subclasses Three approaches: Object-oriented: each entity belongs to exactly one class. Create a relation for each class with all its attributes. E/R style: create one relation for each subclass with only the key attributes and the attributes of the subclass. Entity is represented in all relations to whose subclass entity set it belongs. Null values: create on relation with all attributes. Entities have null values in attributes that do not belong to them. CSCE 520 11/16/2018

Example Subclass Name Breed Dog ISA Show-Dog Rank CSCE 520 11/16/2018

Object-Oriented Approach Name Breed Buddy Mix Dog Name Breed Rank Pepper Germanshepherd 1st Show dog CSCE 520 11/16/2018

E/R Approach Name Breed Pepper Germanshepherd Buddy Mix Name Rank Dog Name Rank Pepper 1st Show dog CSCE 520 11/16/2018

Null Values Name Breed Rank Buddy Mix NULL Pepper Germanshepherd 1st Dog CSCE 520 11/16/2018

Comparisons Object-Oriented: good for queries like “find all G.S. dogs that ranked 2nd or above”. E/R: good for “find all G.S. dogs (regardless of being a show dog or not) Null values: may save space, but not good if too many attributes with null values. CSCE 520 11/16/2018