Database Management Systems Chapter 3 The Relational Data Model (I) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.

Slides:



Advertisements
Similar presentations
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Advertisements

Relational Model Table = relation. Column headers = attributes. Row = tuple Beers Relation schema = name(attributes) + other structure info., e.g., keys,
Chapter 3 : Relational Model
SQL Group Members: Shijun Shen Xia Tang Sixin Qiang.
Tallahassee, Florida, 2014 COP4710 Database Systems Relational Model Fall 2014.
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
Database Management Systems Chapter 3 The Relational Data Model (II) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
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.
Entity-Relationship Model
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.
CPSC-608 Database Systems Fall 2009 Instructor: Jianer Chen Office: HRBB 309B Phone: Notes #2.
The Relational Data Model Database Model (E/R) Relational Schema Physical storage Diagrams (E/R) Tables: row names: attributes rows: tuples Complex file.
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.
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.
1 Entity-Relationship Model Diagrams Class hierarchies Weak entity sets.
CS411 Database Systems Kazuhiro Minami
Chapter 4 The Relational Model Pearson Education © 2014.
Relational Model Session 6 Course Name: Database System Year : 2012.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
Database Management Systems Chapter 3 The Relational Data Model (III) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
Database Management COP4540, SCS, FIU Relational Model Chapter 7.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – Relational Model.
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.
Database Management Systems Chapter 2 The Entity-Relationship Data Model Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
1 Entity-Relationship Model Chapter 2 Copyright : Jeff Ullman + Hank Korth.
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 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
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.
Jennifer Widom Relational Databases The Relational Model.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
© D. Wong Ch. 3 (part 1)  Relational Model basics  From E/R diagram to Relations.
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.
1 Chapter 3 The Relational Data Model. 2 Contents u3.1 Basics of the Relational Model u3.2 From E/R diagrams to Relational Designs u3.4 Functional Dependencies.
CS422 Principles of Database Systems From ER to Relations Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes.
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
CPSC-310 Database Systems
Transformation of E/R Diagram to Relation
ER to Schema.
The Relational Data Model
Functional Dependencies
CS 405G Introduction to Database Systems
CS 505: Intermediate Topics to Database Systems
Instructor: Zhe He Department of Computer Science
CS 405G: Introduction to Database Systems
Presentation transcript:

Database Management Systems Chapter 3 The Relational Data Model (I) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston September, 2006

The Relational Data Model Tables Schemas Conversion from E/R to Relations

Jeffrey Ullman3 A Relation is a Table namemanf WinterbrewPete’s Bud LiteAnheuser-Busch Beers Attributes (column headers) Tuples (rows)

Jeffrey Ullman4 Schemas uRelation schema = relation name and attribute list. wOptionally: types of attributes. wExample: Beers(name, manf) or Beers(name: string, manf: string) uRelation instance = current set of rows. uDatabase = collection of relations. uDatabase schema = set of all relation schemas in the database.

Jeffrey Ullman5 A1 A2 A3... An a1 a2 a3 an b1 b2 a3 cn a1 c3 b3 bn. x1 v2 d3 wn Relational Data Model Set theoretic Domain — set of values like a data type Cartesian product (or product) D1  D2 ...  Dn n-tuples (V1,V2,...,Vn) s.t., V1  D1, V2  D2,...,Vn  Dn Relation-subset of cartesian product of one or more domains FINITE only; empty set allowed Tuples = members of a relation inst. Arity = number of domains Components = values in a tuple Domains — corresp. with attributes Cardinality = number of tuples Relation as table Rows = tuples Columns = components Names of columns = attributes Set of attribute names = schema REL (A1,A2,...,An) Arity CardinalityCardinality Attributes Component Tuple

Jeffrey Ullman6 Name address tel # Cardinality of domain Domains N A T N1 A1 T1 N2 A2 T2 N3 A3 T3 N4 T4 N5 T5 T6 T7 Relation: Example Domain of Relation N A T N1 A1 T1 N1 A1 T2 N1 A1 T3. ……. N1 A1 T7 N1 A2 T1 N1 A3 T1 N2 A1 T1 Arity3 Cardinality<=5x3x7 of relation Tuple µ Domain Component Attribute

Jeffrey Ullman7 Relation Instance NameAddressTelephone Bob123 Main St Bob128 Main St Pat123 Main St Harry456 Main St Sally456 Main St Sally456 Main St Pat12 State St

Jeffrey Ullman8 About Relational Model Order of tuples not important Order of attributes not important (in theory) Collection of relation schemas (intension) Relational database schema Corresponding relation instances (extension) Relational database intension vs. extension schema vs. data metadata includes schema

Jeffrey Ullman9 Why Relations? uVery simple model. uOften a good match for the way we think about our data. uAbstract model that underlies SQL, the most important language in DBMS’s today. wBut SQL uses “bags” while the abstract relational model is set-oriented.

Jeffrey Ullman10 From E/R Diagrams to Relations uEntity set -> relation. wAttributes -> attributes. uRelationships -> relations whose attributes are only: wThe keys of the connected entity sets. wAttributes of the relationship itself.

Jeffrey Ullman11 Keys in Relations An attribute or set of attributes K is a key for a relation R if we expect that in no instance of R will two different tuples agree on all the attributes of K. uIndicate a key by underlining the key attributes.  Example: If name is a key for Beers : Beers(name, manf)

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

Jeffrey Ullman13 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)

Jeffrey Ullman14 Combining Relations uOK to combine into one relation: 1.The relation for an entity-set E 2.The relations for many-one relationships of which E is the “many.” uExample: Drinkers(name, addr) and Favorite(drinker, beer) combine to make Drinker1(name, addr, favBeer).

Jeffrey Ullman15 Risk with Many-Many Relationships uCombining Drinkers with Likes would be a mistake. It leads to redundancy, as: name addr beer Sally 123 Maple Bud Sally 123 Maple Miller Redundancy

Jeffrey Ullman16 Handling Weak Entity Sets uRelation for a weak entity set must include attributes for its complete key (including those belonging to other entity sets), as well as its own, nonkey attributes. uA supporting relationship is redundant and yields no relation (unless it has attributes).

Jeffrey Ullman17 Example LoginsHostsAt name Hosts(hostName, location) Logins(loginName, hostName, billTo) At(loginName, hostName, hostName2) Must be the same billTo At becomes part of Logins location

Jeffrey Ullman18 Subclasses: Three Approaches 1.Object-oriented : One relation per subset of subclasses, with all relevant attributes. 2.E/R style : One relation for each subclass: wKey attribute(s). wAttributes of that subclass. 3.Use nulls : One relation; entities have NULL in attributes that don’t belong to them.

Jeffrey Ullman19 Example Beers Ales isa name manf color

Jeffrey Ullman20 Object-Oriented namemanf BudAnheuser-Busch Beers name manfcolor Summerbrew Pete’sdark Ales Good for queries like “find the color of ales made by Pete’s.”

Jeffrey Ullman21 E/R Style namemanf Bud Anheuser-Busch Summerbrew Pete’s Beers name color Summerbrew dark Ales Good for queries like “find all beers (including ales) made by Pete’s.”

Jeffrey Ullman22 Using Nulls namemanf color Bud Anheuser-Busch NULL Summerbrew Pete’s dark Beers Saves space unless there are lots of attributes that are usually NULL.