ER to Schema.

Slides:



Advertisements
Similar presentations
ER Model For a college DB
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,
Relational Database Design Via ER Modelling
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 Relational Model and Translating ER into Relational.
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.
Methodology Logical Database Design for the Relational 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.
Sept ER-to-Relational Mapping Principles ER-to-Relational Mapping And examples.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations Source: slides by Jeffrey Ullman.
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- and EER-to-Relational Mapping
By Asha,Lia and Mandell. Ash Ketchum  Ash Ketchum is a Pokemon Trainer his first Pokémon was Pikachu he got him in the Kanto Region from professor Oak.
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.
THE ENHANCED ER (EER) MODEL CHAPTER 8 (6/E) CHAPTER 4 (5/E)
© D. Wong Ch. 2 Entity-Relationship Data Model (continue)  Data models  Entity-Relationship diagrams  Design Principles  Modeling of constraints.
 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
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj ER Model Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003, 2004,
CST203-2 Database Management Systems Lecture 4. Student entity NIDFNameLNameRegNoExamIdBirthdate.
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.
Modeling Data in the Organization Muhammad Nasir
Pokémon By, Eugena and Michael. Where did the cards come from? The first Pokémon card was made in japan on stone in 1877.
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.
COP Introduction to Database Structures
Introduction to Database Systems, CS420
ERwin.
Relational Database Design by ER- and EER-to- Relational Mapping
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.
Methodology Logical Database Design for the Relational Model
Relational Database Design by ER- and EER-to- Relational Mapping
Entity-Relationship Diagrams
COP4710 Database Systems E-R Model.
ER- and EER-to-Relational
Relational Database Design by ER- and EERR-to-Relational Mapping
Relational Database Design by ER-to-Relational Mapping
INF385T: Information Modeling — Class 11 Relational Database Design from ER Models Presented November 2 Karen Wickett,
Constraints in Entity-Relationship Models
CPSC 315 – Programming Studio Fall 2009 Project 1, Lecture 2
How to translate ER Model to Relational Model
CPSC-310 Database Systems
Order Database – ER Diagram
Transformation of E/R Diagram to Relation
From E/R Diagrams to Relational Schema
Transforming E/R to Relational Model.
Chapter 8: Mapping a Conceptual Design into a Logical Design
IST 318 Database Administration
The Entity-Relationship Model
Functional Dependencies
Relational Database Design by ER- and EER-to-Relational Mapping
Functional Dependencies
Lecture 5: The Relational Data Model
Relational Database Design by ER- and EER-to- Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
The Relational Data Model
CS 405G Introduction to Database Systems
CS 505: Intermediate Topics to Database Systems
Relational Database Design by ER- and EER-to-Relational Mapping
Database Dr. Roueida Mohammed.
Session 5: Weak Entity Sets and ER Model to Relational ( )
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

ER to Schema

From E/R Diagrams to Relations Entity Set -> Relation. Attributes -> Attributes. Relationships -> Relations whose attributes are only: The keys of the connected entity sets. Attributes of the relationship itself.

Entity Set -> Relation Pokémon(name, species) name Pokémon species

Relationship -> Relation Pokémon(name, species) Trainer(name) Belongs(p_name, t_name) Fought(attacker, defender) name name belongs Trainer defender Pokémon attacker species fought

Combining Relations You can "combine" relations together: Pokémon(name, species) + Belongs(p_name, t_name) becomes: Pokémon(name, species, trainer) Rule: You can combine in the relationship sets with an entity set, if that set is the "many" part of a many- to-one relationship.

Can we combine Trainers and Fought? 1. No, cyclical relationships sets can't be merged 2. Yes, yielding Trainer(name, badges, defender) 3. No, the "fought" relation is not many- to-one 4. The Pokémon references are silly name badges Trainer defender attacker fought

Many-to-Many Combination Combining "Fought" with "Trainers" leads to redundancy. Trainers Fought Combined name badges Ash 8 Brock 2 Misty 3 Oak attacker defender Ash Brock Misty name badges defender Ash 8 Brock 2 Misty 3 NULL Oak Redundancy! See badges.

Weak Entity Sets to Relations Relation for a weak entity set must include attributes for its complete key (including those belonging to other entity sets), as well as its own, non-key attributes. A supporting relationship is redundant and yields no relation (unless it has attributes). Relations: Pokémon(name, position) Status(effect, duration, position) Has(effect, position) Redundant position name has Pokémon Status effect duration

Subclasses: 3 methods Nulls: One relation; entities have NULL in attributes that don't belong to them Object-oriented: One relation per subset of subclasses, with all relevant attributes E/R style: One relation for each subclass: Key attributes Attributes of that subclass

Example: Nulls isa isa name type Pokémon name type owner run_away Abra psychic NULL True Pikachu electric Red False Onix rock Brock Mew Pokémon isa isa owner Caught Pokémon Wild Pokémon run_away

Example: Object-oriented Pokémon name type name type Mew psychic Pokémon Wild Pokémon name type run_away Abra psychic True isa isa Caught Pokémon name type owner Onix rock Brock Caught and Wild Pokémon owner Caught Pokémon Wild Pokémon run_away name type owner run_away Pikachu electric Red False

Example: E/R style isa isa name type Pokémon Caught Pokémon name type Abra psychic Pikachu electric Onix rock Mew name owner Onix Brock Pikachu Red Pokémon isa isa Wild Pokémon name run_away Abra True Pikachu False owner Caught Pokémon Wild Pokémon run_away

Which method to handle subclasses is best? 1. Object-oriented 2. Nulls 3. E/R style 4. Depends