1 Convert E/R to Relation May 18, 2015. 2 Entity Set -> Relation Relation: Beers(name, manf) Beers name manf.

Slides:



Advertisements
Similar presentations
Banking Business Scenario
Advertisements

ER Model For a college DB
Database Management Systems Chapter 3 The Relational Data Model (I) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
1–1 Students Entity/Relationship Model Diagrams to represent designs. Entity like object, = “thing.” Entity set like class = set of “similar” entities/objects.
CSCI 305 – Fall 2013 The Entity-Relationship Model Based on Slides by Prof. Brian King.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
1 Entity-Relationship Model Diagrams Class hierarchies Weak entity sets.
Databases : Relational Model 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey D. Ullman distributes.
Entity-Relationship Model
Chapter 4 Notes. Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
Design Principles: Faithfulness
Entity-Relationship Model. The process of designing a database begins with: –an analysis of what information the database must hold, and –the relationships.
Design Principles: Faithfulness
1 Relational Model and Translating ER into Relational.
The Relational Data Model Database Model (E/R) Relational Schema Physical storage Diagrams (E/R) Tables: row names: attributes rows: tuples Complex file.
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.
Movies length titleyearfilmType Voices isa Cartoons isa MurderMystery weapon toStar Our Movie Example.
A four-way Relationship
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.
Fall 2001Arthur Keller – CS 1803–1 Schedule Today Oct. 2 (T) Relational Model. u Read Sections Assignment 1 due. Personal Letter of Introduction.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations Source: slides by Jeffrey Ullman.
Winter 2002Arthur Keller – CS 1803–1 Schedule Today: Jan. 10 (TH) u Relational Model, Functional Dependencies. u Read Sections Jan. 15 (T) u Normal.
CS411 Database Systems Kazuhiro Minami
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
1 Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
Databases : Entity-Relationship Model 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey D. Ullman.
ER Data Models Ctd. CSET 3300.
Conversion E/R to Relational CIS 4301 Lecture Notes Lecture 6 - 1/31/2006.
The Hong Kong University of Science and Technology COMP3311 Spring 2013 Tutorial 1 ER Diagrams.
Normalization Exercise. First Normal Form Second Normal Form.
Tallahassee, Florida, 2015 COP4710 Database Systems E-R Model Fall 2015.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Entity-Relationship Model
 Primary keys allow entity sets and relationship sets to be expressed uniformly as relations  E/R diagram  collection of tables  For each entity set.
Data Modeling Translating E-R Diagrams to Relations
Dale Roberts 11/26/ Department of Computer and Information Science, School of Science, IUPUI Fall 2003 Dale Roberts, Lecturer Computer Science, IUPUI.
CS 405G: Introduction to Database Systems Lecture 5: Logical Design by Relational Model Instructor: Chen Qian.
Databases 1 Fifth lecture. Entity-Relationship Model Diagrams Class hierarchies Weak entity sets From E/R diagrams to Relations 2.
Instructor: Jinze Liu Fall Phases of Database Design u Conceptual design begins with the collection of requirements and results needed from the.
Santa Clara UniversityHolliday – COEN 1783–1 Today’s Topic Today: u Relational Model, Functional Dependencies. u Read Sections Next time u Normal.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
Entity-Relationship Model E/R Diagrams Converting E/R Diagrams to Relations.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations Functional Dependencies.
CS 405G: Introduction to Database Systems Relations.
Functional Dependencies. Babies Exercise 2.2.5: At a birth, there is one baby (twins would be represented by two births), one mother, any number of nurses,
1 Unified Modeling Language. 2 UML  UML is designed to model software, but has been adapted as a database modeling language. – No multiway relationships.
© D. Wong Ch. 3 (part 1)  Relational Model basics  From E/R diagram to Relations.
CS422 Principles of Database Systems Convert ER Design to Relations Chengyu Sun California State University, Los Angeles.
CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles.
High-level Database Models Prof. Yin-Fu Huang CSIE, NYUST Chapter 4.
A short revision on entity- relationship modelling.
A short review on entity- relationship modelling.
1 Database Design: DBS CB, 2 nd Edition Logical Database Model: Entity Relationship Model & Object Description Language & Unified Modeling Language Ch.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
The Entity-Relationship Diagram for Data Modeling
CS422 Principles of Database Systems From ER to Relations Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes.
CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture.
Introduction to Database Systems, CS420
Entity-Relationship Model
Cushing, Keller, UlmanJudy Cushing
CPSC-310 Database Systems
Instructor: Zhe He Department of Computer Science
CPSC-310 Database Systems
Transformation of E/R Diagram to Relation
The Relational Data Model
CS 405G Introduction to Database Systems
CS 505: Intermediate Topics to Database Systems
CS 405G: Introduction to Database Systems
Presentation transcript:

1 Convert E/R to Relation May 18, 2015

2 Entity Set -> Relation Relation: Beers(name, manf) Beers name manf

3 Relationship -> Relation DrinkersBeers Likes Likes(drinker, beer) Favorite Favorite(drinker, beer) Married husband wife Married(husband, wife) name addr name manf Buddies 1 2 Buddies(name1, name2)

4 Weak Entity Set -> Relation LoginsHostsAt name Hosts(name, location) Logins(loginName, hostName, billTo) billTo location

5 Exercise # 1 Construct an E/R diagram for a hospital with a set of patients and a set of physicians. Associate with each patient a log of the various tests conducted, along with the date and time of the test. Convert the E/R diagram into relational schemas.

6 Physician( name, specialization) Patient( ss#, name, insurance) DoctorPatient( name, ss#) TestLog( ss#, testName, testTime, date)

7 Combining Relations It is OK to combine an entity set E with a relationship R if the multiplicity for the relationship is many-to-one, where E is the “many.”

8 Example – Combine Relations DrinkersBeers Favorite name addr name manf Drinkers(name, addr) and Favorite(drinker, beer) can be combined to: Drinkers(name, addr, favBeer)

9 Exercise # 2 Draw an E/R diagram for the following: Manufacturers have an unique name, an address, and a phone. Products have a model number and a type (e.g. "TV set"). Each product is made by one manufacture, and different manufacturers may have different products with the same model number. However, you may assume that no manufacturer would have 2 products with the same model number. Customers are identified by their unique social security number. An order has unique order number and a date. An order is placed by one customer. For each order, there are one or more products ordered, and there is a quantity for each product on the order.

10 Solution # 3 OrderDetail( order#, name, model, quantity) Manf( name, addr, phone) Product( name, model#, type) Orders( order#, date, ssNo) Customers( ssNo, addr, )

11 Question #3 Convert the Enrollment relationship in the following E/R diagram into entity set. Convert the new E/R diagram into relational schemas. Enrollment number description Course credit GPA address id Student name Grade

12 Student(id, Name, GPA, address) Course(number, description, credit) Enrollment(id, number, grade)

13 Subclass -> Relation w 3 Approaches: 1. Straight E/R method 2. Object-Oriented method 3. Null method

14 Straight E/R Method 1. Straight E/R method One relation for each subclass Include: Key attribute(s) of parent Attributes of that subclass.

15 Example - Straight E/R Method namemanf Bud Anheuser-Busch Summerbrew Pete’s Beers name color Summerbrew dark Ales Beers Ales isa name manf color

16 Exercise #4 – Straight E/R Movie(title, year, length, filmType) Cartoon(title, year, software) MurderMystery(title, year, weapon) length filmType title year Movie weapon Murder- Mystery isa Cartoon software

17 Object-Oriented Method 2. Object-Oriented method : One relation per subset of subclasses, with all relevant attributes

18 Example - OO Method namemanf BudAnheuser-Busch Beers name manfcolor Summerbrew Pete’sdark Ales Beers Ales isa name manf color

19 Exercise #5 – OO Method Movie(title, year, length, filmType) MovieCartoon(title, year, length, filmType, software) MovieMurderMystery(title, year, length, filmType, weapon) MovieCartoonMurderMyst(title, year, length, filmType, software, weapon) length filmType title year Movie weapon Murder- Mystery isa Cartoon software

20 Null Method 3. Null method : One relation Entities have NULL in attributes that don’t belong to them

21 Null Method namemanf color Bud Anheuser-Busch NULL Summerbrew Pete’s dark Beers Probably faster query execution (no joins), but uses more space if there are lots of attributes that are NULL. Beers Ales isa name manf color

22 Exercise #6 – NULL Method Movie(title, year, length, filmType, software, weapon) length filmType title year Movie weapon Murder- Mystery isa Cartoon software