CPSC 315 – Programming Studio Fall 2009 Project 1, Lecture 2

Slides:



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

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.
Overview of Database Systems CPSC 315 – Programming Studio Spring 2009 Team Project 1, Lecture 1.
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.
SQL Queries CPSC 315 – Programming Studio Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch, via Yoonsuck Choe.
Databases : Relational Model 2007, Fall Pusan National University Ki-Joune Li These slides are made from the materials that Prof. Jeffrey D. Ullman distributes.
SQL Queries CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 4 Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch.
Database Implementation Issues CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 5 Slides adapted from those used by Jennifer Welch.
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.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations Source: slides by Jeffrey Ullman.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to- Relational Mapping.
©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.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch Via Yoonsuck Choe.
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.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
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.
IS 230Lecture 4Slide 1 Entity Relationship to Relational Model Mapping Lecture 5.
© 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.
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)
DatabaseIM ISU1 Chapter 7 ER- and EER-to-Relational Mapping Fundamentals of Database Systems.
The Entity-Relationship Model CIS 4301 Lecture Notes 1/12/2006.
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.
CS422 Principles of Database Systems Entity-Relationship Model
Introduction to Database Systems, CS420
ERwin.
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.
Relational Database Design by ER- and EER-to- Relational Mapping
EER Model – Chapter
RELATION.
Entity-Relationship Model
Tables and Their Characteristics
ER- and EER-to-Relational
CPSC-310 Database Systems
Database Implementation Issues
CSCE 315, Fall 2017 Project 1, Lecture 2
CPSC-310 Database Systems
Transformation of E/R Diagram to Relation
Overview of Database Systems
Solution Problem1 Exam0 ssn Sal empl. name name Person Team city contr
Database Implementation Issues
Overview of Database Systems
SQL OVERVIEW DEFINING A SCHEMA
Lecture 06 Data Modeling: E/R Diagrams
Session 2 Welcome: The seventh learning sequence
CSCE 315 – Programming Studio Spring 2010 Project 1, Lecture 4
The Entity-Relationship Model
Overview of Database Systems
Lecture 9: The E/R Model II
DATABASE IMPLEMENTATION ISSUES
Lecture 5: The Relational Data Model
ER to Schema.
The Relational Data Model
Database Implementation Issues
Introduction to modeling
Overview of Database Systems
Session 5: Weak Entity Sets and ER Model to Relational ( )
Database Implementation Issues
CPSC 315 – Programming Studio Spring 2017 Project 1, Part 3
CSCE 315, Spring 2019 Project 1, Part 3 Robert Lightfoot
Presentation transcript:

CPSC 315 – Programming Studio Fall 2009 Project 1, Lecture 2 Relational Databases CPSC 315 – Programming Studio Fall 2009 Project 1, Lecture 2 Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch

Relational Data Model Relations are stored in tables e.g. Sponsor(Senator,Bill) Atrributes Sponsor Senator Bill Smith Tax Jones Defense Adams Commerce Tuples

Schemas A relation schema is a relation name and a list of attributes Sponsor(Senator,Bill) A database is a collection of relations A database schema is the set of all the relation schemas in the database

Converting from Entity-Relationship Model ER: Entity set -> relation ER Attributes become Relational attributes ER: Relationship -> relation Keys of connected ER entity sets become Relational attributes

ER Entity Sets Name Party Organization Senator Lobbyist State Name Years Bill Name Text

Relations Senator(Name,Party,State,Years) Bill(Name,Text) Lobbyist(Name,Organization)

ER Relationships Name Contributed Party Organization Senator Lobbyist State Sponsored Name Years Wrote Bill Name Text

Relations Sponsored(Senator,Bill) Wrote(Bill,Lobbyist) Contributed(Senator,Lobbyist) Remember, each of these is expressed as a table (with the columns given by the “parameters”) Notice that columns can refer to “bigger” items, with even more attributes

Combining Relations Relations can sometimes be combined. Assume a “base” entity set with its relation. If there is a many-to-one relation, that can be combined with the base entity set. Should not combine many-to-many Redundancy – each of the many stored

Combining Relations Example (many-to-one): (Good) Person(Name, Birthdate, Height, Weight, Eye Color, Hair Color) BornIn(Person,Town) Person(Name, Birthdate, Height, Weight, Eye Color, Hair Color, Town) Example(many-to-many): (Bad) Senator(Name, Party, State, Years) Sponsored(Senator, Bill) Senator(Name, Party, State, Years, Bill)

Weak Entity Sets The relation for a weak entity set must contain all the elements of its key Supporting relationships are usually redundant (unless possibly multi-way)

Weak Entity Set Example First Name Last Name Number Note arrrow: indicates many to one. Baseball Player Position Birthdate Plays On Team Nationality Salary Name City

Weak Entity Set Example Team(Name, City) Baseball Player(Number, TeamName, First Name, Last Name, Position, Birthdate, Nationality, Salary)

Weak Entity Set Example Team(Name, City) Baseball Player(Number, TeamName, First Name, Last Name, Position, Birthdate, Nationality, Salary) Note that we don’t need PlaysOn(BaseballPlayer.Number, BaseballPlayer.TeamName, Team.Name)

Weak Entity Set Example Team(Name, City) Baseball Player(Number, TeamName, First Name, Last Name, Position, Birthdate, Nationality, Salary) Note that we don’t need PlaysOn(BaseballPlayer.Number, BaseballPlayer.TeamName, Team.Name) Redundant (same)

Weak Entity Set Example Team(Name, City) Baseball Player(Number, TeamName, First Name, Last Name, Position, Birthdate, Nationality, Salary) Note that we don’t need PlaysOn(BaseballPlayer.Number, BaseballPlayer.Team.Name)

Weak Entity Set Example Team(Name, City) Baseball Player(Number, TeamName, First Name, Last Name, Position, Birthdate, Nationality, Salary) Note that we don’t need PlaysOn(BaseballPlayer.Number, BaseballPlayer.Team.Name) Already Included

Subclasses Different Options Different ways to represent subclasses Name Elected Official Party isa U.S. Representative District

Object-Oriented Style One relation for each subset, including all “inherited” attributes Elected Official Name Party Chet Edwards Democrat John Cornyn Republican John Adams Federalist Ron Paul U.S. Representative Name Party District Chet Edwards Democrat 17 Ron Paul Republican 14

Entity-Relationship Style One relation for each subclass (including key) Elected Official Name Party Chet Edwards Democrat John Cornyn Republican John Adams Federalist Ron Paul U.S. Representative Name District Chet Edwards 17 Ron Paul 14

Using Nulls Style One relation total, with nulls for unknown information Can save space, but problematic if multiple subclasses or lots of NULLs U.S. Representative Name Party District Chet Edwards Democrat 17 John Cornyn Republican NULL John Adams Federalist Ron Paul 14

Keys A Key “functionally determines” all other attributes of the relation Given a relation and a key, there is only one tuple that corresponds to it There are subtle differences from an E-R key, which we won’t go into.