CS 405G: Introduction to Database Systems Relations.

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,
Database Management Systems Chapter 3 The Relational Data Model (I) Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
Chapter 3 : Relational Model
SQL Group Members: Shijun Shen Xia Tang Sixin Qiang.
Tallahassee, Florida, 2014 COP4710 Database Systems Relational Model Fall 2014.
CSCI 305 – Fall 2013 The Entity-Relationship Model Based on Slides by Prof. Brian King.
Winter 2002Arthur Keller – CS 1806–1 Schedule Today: Jan. 22 (T) u SQL Queries. u Read Sections Assignment 2 due. Jan. 24 (TH) u Subqueries, Grouping.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
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.
Winter 2002Arthur Keller – CS 18016–1 Schedule Today: Mar. 5 (T) u More ODL, OQL. u Read Sections 9.1. Assignment 7 due. Mar. 7 (TH) u More OQL. u Read.
1 Introduction to Database Systems Ref. Ramakrishnan & Gehrke Chapter 1.
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.
Fall 2001Arthur Keller – CS 1803–1 Schedule Today Oct. 2 (T) Relational Model. u Read Sections Assignment 1 due. Personal Letter of Introduction.
CS 405G: Introduction to Database Systems Lecture 4: Relational Model Instructor: Chen Qian.
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.
Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Copyright © 2004 Pearson Education, Inc. Slide 2-1 Data Models Example: A relation.
1 The Relational Data Model Tables Schemas Conversion from E/R to Relations.
CSCE 520- Relational Data Model Lecture 2. Relational Data Model The following slides are reused by the permission of the author, J. Ullman, from the.
Databases 1 First lecture. Informations Lecture: Monday 12:15-13:45 (3.716) Practice: Thursday 10:15-11:45 (2-519) Website of the course:
1 Entity-Relationship Model E/R Diagrams Weak Entity Sets Converting E/R Diagrams to Relations.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
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.
12/2/2015CPSC , CPSC , Lecture 41 Relational Model.
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.
CSCE 520- Relational Data Model Lecture 2. Oracle login Login from the linux lab or ssh to one of the linux servers using your cse username and password.
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.
CPSC 603 Database Systems Lecturer: Laurie Webster II, M.S.S.E., M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 4 Introduction to a First Course in Database Systems.
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.
Jennifer Widom Relational Databases The Relational Model.
Faeez, Franz & Syamim.   Database – collection of persistent data  Database Management System (DBMS) – software system that supports creation, population,
Computational Biology Dr. Jens Allmer Lecture Slides Week 5.
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.
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
The Relational Model.
COP4710 Database Systems Relational Model.
Cushing, Keller, UlmanJudy Cushing
CPSC-310 Database Systems
CS 440 Database Management Systems
Instructor: Zhe He Department of Computer Science
Database Models Relational Model
CPSC-310 Database Systems
CPSC-310 Database Systems
Relational Databases The Relational Model.
Relational Databases The Relational Model.
The Relational Data Model
CS4433 Database Systems Relational Model.
CS 405G Introduction to Database Systems
CS 505: Intermediate Topics to Database Systems
CS 405G: Introduction to Database Systems
Presentation transcript:

CS 405G: Introduction to Database Systems Relations

2/13/20162 Review  A data model is  a group of concepts for describing data.  What are the two terms used by ER model to describe a miniworld?  Entity  Relationship  What makes a good database design Student (sid: string, name: string, login: string, age: integer, gpa:real) 22/13/2016

3 Topics Next  Conversion of ER models to Schemas  Reading Assignment  Chapter 3.1, /13/2016

4 Database Design 42/13/2016

A Relation is a Table 5 name manf WinterbrewPete’s Bud LiteAnheuser-Busch Beers Attributes (column headers) Tuples (rows)

Schemas 6  Relation schema = relation name + attributes, in order (+ types of attributes).  Example: Beers(name, manf) or Beers(name: string, manf: string)  Database = collection of relations.  Database schema = set of all relation schemas in the database.

Why Relations? 7  Very simple model.  Often matches how we think about data.  Abstract model that underlies SQL, the most important database language today.  But SQL uses bags, while the relational model is a set-based model.

From E/R Diagrams to Relations 8  Entity sets become relations with the same set of attributes.  Relationships become relations whose attributes are only:  The keys of the connected entity sets.  Attributes of the relationship itself.

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

Relationship -> Relation 10 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)

Combining Relations 11  It is OK to combine the relation for an entity-set E with the relation R for a many-one relationship from E to another entity set.  Example: Drinkers(name, addr) and Favorite(drinker, beer) combine to make Drinker1(name, addr, favBeer).

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

Handling Weak Entity Sets 13  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, nonkey attributes.  A supporting (double-diamond) relationship is redundant and yields no relation.

Example 14 LoginsHostsAt name time

Example 15 LoginsHostsAt name Hosts(hostName) Logins(loginName, hostName, time) At(loginName, hostName, hostName2) Must be the same time At becomes part of Logins

16 A (Slightly) Formal Definition  A database is a collection of relations (or tables)  Each relation is identified by a name and a list of attributes (or columns)  Each attribute has a name and a domain (or type)  Set-valued attributes not allowed 16

2/13/ Schema versus instance  Schema (metadata)  Specification of how data is to be structured logically  Defined at set-up  Rarely changes  Instance  Content  Changes rapidly, but always conforms to the schema  Compare to type and objects of type in a programming language 172/13/2016

18 Example  Schema  Student (SID integer, name string, age integer, GPA float)  Course (CID string, title string)  Enroll (SID integer, CID integer)  Instance  { h 142, Bart, 10, 2.3 i, h 123, Milhouse, 10, 3.1 i,...}  { h CPS116, Intro. to Database Systems i,...}  { h 142, CPS116 i, h 142, CPS114 i,...} 182/13/2016