 Primary keys allow entity sets and relationship sets to be expressed uniformly as relations  E/R diagram  collection of tables  For each entity set.

Slides:



Advertisements
Similar presentations
Banking Business Scenario
Advertisements

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,
R ELATIONAL M ODEL TO SQL Data Model. 22 C ONCEPTUAL D ESIGN : ER TO R ELATIONAL TO SQL How to represent Entity sets, Relationship sets, Attributes, Key.
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.
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.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
The Entity-Relationship Model
1 Convert E/R to Relation May 18, Entity Set -> Relation Relation: Beers(name, manf) Beers name manf.
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.
Design Principles: Faithfulness
Weak Entity Sets. Occasionally, entities of an entity set need “help” to identify them uniquely. Example. Crews might have a number and some description,
Weak Entity Sets. Occasionally, entities of an entity set need “help” to identify them uniquely. Entity set E is weak if in order to identify entities.
1 Relational Model and Translating ER into Relational.
From ER Diagrams to the Relational Model Rose-Hulman Institute of Technology Curt Clifton.
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.
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.
The Entity-Relationship Data Model
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.
ER continued, and ER to Relational Mappings R&G Chapters 2, 3 Lecture 22.
©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.
Introduction to Databases
CS411 Database Systems Kazuhiro Minami
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.
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,
DATABASE MANAGEMENT SYSTEMS BASIC CONCEPTS 1. What is a database? A database is a collection of data which can be used: alone, or alone, or combined /
DATABASE MANAGEMENT SYSTEMS BASIC CONCEPTS 1. What is a database? A database is a collection of data which can be used: alone, or alone, or combined /
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
What we’ve learnt Doc 5.69 Doc 5.70 Section 1-3. A simple database Related objects Tables hold the data Forms, reports, queries to access the data.
Relational Databases CPSC 315 – Programming Studio Spring 2013 Project 1, Lecture 2 Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch.
EXAMPLE. Subclasses and Superclasses Entity type may have sub-grouping that need to be represented explicitly. –Example: Employee may grouped into.
The Relational Model1 ER-to-Relational Mapping and Views.
IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5.
 Entity-relationship models (ERM) Entity-relationship models (ERM)  Simple E-R Diagram Simple E-R Diagram  Weak Entity Weak Entity  Strong Entity.
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
Entity-Relationship Model
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
1 Translating ER Schema to Relational Model Instructor: Mohamed Eltabakh
Data Modeling Translating E-R Diagrams to Relations
Entity Relationship Diagram (2)
E-R to Relational - Basic
SAnta Clara UniversityHolliday – COEN 1782–1 Today’s Topic Today: u Constraints, Weak Entity Sets, Entity- Relationship Design. u Read Sections
Lecture 3 Book Chapter 3 (part 2 ) From ER to Relational.
Databases 1 Fifth lecture. Entity-Relationship Model Diagrams Class hierarchies Weak entity sets From E/R diagrams to Relations 2.
The Entity-Relationship Model CIS 4301 Lecture Notes 1/12/2006.
Entity-Relationship Model E/R Diagrams Converting E/R Diagrams to Relations.
CS 405G: Introduction to Database Systems Relations.
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.
© 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.
Modeling: Entity-Relationship Diagrams
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.
CPSC-310 Database Systems
Order Database – ER Diagram
Transformation of E/R Diagram to Relation
Functional Dependencies
ER to Schema.
The Relational Data Model
Presentation transcript:

 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 11/15/2015CSCE 5202

 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 11/15/2015CSCE 5203

11/15/2015CSCE 5204 Example E/R Diagram Dog Name Breed Age License # Phone Weight Name Phone Address Owns Owner Kennel Pays Boards Amount

11/15/2015CSCE 5205 Entity Set to Relation Dog Name Breed Age Weight Dog(Name,Breed,Age,Weight)

11/15/2015CSCE 5206 Entity Set to Relation OwnerKennel Pays AmountName Address Pays(Kennel. Name,Owner.Name,Amount,Date) Phone Date

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

11/15/2015CSCE 5208 Combining Relations: Many-Many OwnerKennel Pays Name Address Combining Owner with pays: Owner(Kennel.Name,Owner.Name,Phone) Phone

Kennel Name Owner Name Owner Phone White OakMary Little CreekMary White OakViki White OakJoe /15/2015CSCE 5209 Redundancy

 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 11/15/2015CSCE 52010

11/15/2015CSCE Dog Name Breed Age Owner Owns Name Phone Owner(Owner.Name, Phone) Dog(Dog.Name,Owner.Name, Age,Breed) Owns(Dog.Name,Owner.Name1,Owner.Name2) Must be the same Already in Dog Redundant!

Three approaches: 1. Object-oriented: each entity belongs to exactly one class. Create a relation for each class with all its attributes. 2. 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. 3. Null values: create on relation with all attributes. Entities have null values in attributes that do not belong to them. 11/15/2015CSCE 52012

11/15/2015CSCE Example Subclass Dog NameBreed Show-Dog Rank ISA

11/15/2015CSCE Object-Oriented Approach NameBreed BuddyMix NameBreedRank PepperGermanshepherd1st Dog Show dog

11/15/2015CSCE NameBreed PepperGermanshepherd BuddyMix NameRank Pepper1st Dog Show dog

11/15/2015CSCE Null Values NameBreedRank BuddyMixNULL PepperGermanshepherd1st Dog

 Object-Oriented: good for queries like “find all G.S. dogs that ranked 2 nd 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. 11/15/2015CSCE 52017