CS 480: Database Systems Lecture 8 February 1, 2013.

Slides:



Advertisements
Similar presentations
Transform an ER Model into a Relational Database Schema
Advertisements

CH4 EXERCISES 4.2. Given two relations R1 and R2, where R1 contains N1 tuples, R2 contains N2 tuples, and N2 > N1 > 0, give the min and max possible sizes.
COMP 5138 Relational Database Management Systems Semester 2, 2007 Lecture 5A Relational Algebra.
IS698: Database Management Min Song IS NJIT. The Relational Data Model.
1 Relational Algebra* and Tuple Calculus * The slides in this lecture are adapted from slides used in Standford's CS145 course.
Relational Algebra Tim Kaddoura CS157A. Introduction  Relational query languages are languages for describing queries on a relational database  Three.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
Relational Algebra Ch. 7.4 – 7.6 John Ortiz. Lecture 4Relational Algebra2 Relational Query Languages  Query languages: allow manipulation and retrieval.
INFS614, Fall 08 1 Relational Algebra Lecture 4. INFS614, Fall 08 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of.
Spring 2003 ECE569 Lecture 02.1 ECE 569 Database System Engineering Spring 2003 Yanyong Zhang
1 Data Models How to structure data. 2 What is a Data Model? Having formed a model of the enterprise, we now need to represent the data. The data model.
Relational Algebra Chapter 4 - part I. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
CSCD343- Introduction to databases- A. Vaisman1 Relational Algebra.
Computer Science & Engineering 2111 CSE 2111 Lecture Querying a Database 1CSE 2111 Lecture- Querying a Database.
Fractions and Decimals 5.2. Writing a Fraction as a decimal Divide the numerator by the denominator.
Database Management Systems,1 Relational Calculus.
1.1 CAS CS 460/660 Introduction to Database Systems Relational Algebra.
Algebra1 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and Relational Algebra expressions.
Query and Reasoning. Types of Queries Most GIS queries will select spatial features Query by Attribute (Select by Attribute) –Structured Query Language.
Database Management Systems 1 Raghu Ramakrishnan Relational Algebra Chpt 4 Xin Zhang.
CSCD34-Data Management Systems - A. Vaisman1 Relational Algebra.
COMP3030 Database Management System Final Review
CMPT 258 Database Systems Relational Algebra (Chapter 4)
CSC271 Database Systems Lecture # 7. Summary: Previous Lecture  Relational keys  Integrity constraints  Views.
Database Management Systems 1 Raghu Ramakrishnan Relational Algebra Chpt 4 Jianping Fan.
1 CSE 480: Database Systems Lecture 16: Relational Algebra.
Reports. Reports display information retrieved from a database in an attractive printed format. Reports can be created directly from tables, but More.
1 Relational Algebra & SQL Query Formulation Exercise.
Database Systems (資料庫系統)
CPSC-310 Database Systems
CS 480: Database Systems Lecture 17 February 22, 2013.
CS 480: Database Systems Lecture 12 February 11, 2013.
CS 480: Database Systems Lecture 4 January 23, 2013.
CS4432: Database Systems II
CS 480: Database Systems Lecture 13 February 13,2013.
Relational Algebra and SQL
CS 480: Database Systems Lecture 9 February 4, 2013.
CS 480: Database Systems Lecture 15 February 18, 2013.
Multiplying and Dividing Rational Expressions
1 Introduction to Algebra: Integers.
CPSC-310 Database Systems
CS 440 Database Management Systems
SQL: Structured Query Language DML- Queries Lecturer: Dr Pavle Mogin
Lecture #4: Relational Algebra
Relational Algebra 461 The slides for this text are organized into chapters. This lecture covers relational algebra, from Chapter 4. The relational calculus.
Database Systems 10/13/2010 Lecture #4.
Relational Algebra.
Discrete Structures for Computer Science
Lecture 4 of 42 Relational Joins Wednesday, 30 January 2008
Session 3 Welcome: To session 3 - the 7th. learning sequence
The Entity-Relationship Model
LECTURE 3: Relational Algebra
Relational Algebra Chapter 4 - part I.
Lesson 2 Introductory Algebra Powers and Exponents.
Relational Algebra Chapter 4, Sections 4.1 – 4.2
Adding AND Subtracting Rational Expressions
Relational Algebra.
Chapter 2: Intro to Relational Model
Session 3 Welcome: To session 3-the 8th. learning sequence
INFO/CSE 100, Spring 2006 Fluency in Information Technology
실습 4주차.
Database Dr. Roueida Mohammed.
Topic 12 Lesson 2 – Retrieving Data with Queries
7-4 Division Properties of Exponents
Adding and Subtracting Rational Expressions
Microsoft Access Date.
Instructor: Zhe He Department of Computer Science
CSE544 Wednesday, March 29, 2006.
Some examples of simple business rules:
Lecture 2 Relational Database
Presentation transcript:

CS 480: Database Systems Lecture 8 February 1, 2013

Division () Let r(R) and s(S) be relations such that S  R. Then r  s consists of every tuple t in ΠR–S(r) that satisfies the following condition: If every tuple in s is appended to t, then the resulting tuple is in r. The result is defined over the scheme R-S.

Division () Numerator: Denominator: Supplier-id Part-id 1 2 3 4 5 6 Result: Supplier-id 1 4

Division () What are the student-id’s of students who took both 480 and 580, and got an A in both? Enrollment: s: Student-id Course# Grade 23 480 A 580 25 230 B+ 250 C 28 Course# Grade 480 A 580 Enrollment  s Student-id 23 28

Division () What are the student-id’s of students who took both 480 and 580, and got an A in both? Enrollment: What’s an alternative algebra expression that would answer this query? Student-id Course# Grade 23 480 A 580 25 230 B+ 250 C 28 Select students with A in 480 Select students with A in 580 Project their student-id’s Compute Intersection

Examples #1 Relational Schema order(order#,retailer-name,item,quantity) supplier(supp#,supp-name,item,price)

Examples #1 Relational Schema Query order(order#,retailer-name,item,quantity) supplier(supp#,supp-name,item,price) Query Retrieve the name of suppliers that supply every item that was endorsed by ‘Jewel’

Examples #1 Relational Schema Query order(order#,retailer-name,item,quantity) supplier(supp#,supp-name,item,price) Query Retrieve the name of suppliers that supply every item that was endorsed by ‘Jewel’ Gives us a clue that we want to do a division.

Examples #1 Relational Schema Query order(order#,retailer-name,item,quantity) supplier(supp#,supp-name,item,price) Query Retrieve the name of suppliers that supply every item that was endorsed by ‘Jewel’ Think of the target. We want just the supp-name. Also they have in common the ITEM and that’s what should be repeated Gives us a clue that we want to do a division. What’s the numerator and what’s the denominator?

Examples #1 Relational Schema Query Relational Algebra Query order(order#,retailer-name,item,quantity) supplier(supp#,supp-name,item,price) Query Retrieve the name of suppliers that supply every item that was endorsed by ‘Jewel’ Relational Algebra Query Πsupp-name,item(X)  Πitem(Y) WHAT IS Y? Y should be “every item that was ordered by Jewel” WHAT IS X? We want to get the suppliers so then we should put it as X.

Examples #1 Relational Schema Query Relational Algebra Query order(order#,retailer-name,item,quantity) supplier(supp#,supp-name,item,price) Query Retrieve the name of suppliers that supply every item that was endorsed by ‘Jewel’ Relational Algebra Query Πsupp-name,item(supplier)  Πitem(σretailer-name=‘Jewel’(order))

Examples #2 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity)

Examples #2, Query #1 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Steps to take?

Examples #2, Query #1 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Steps to take? Select the shipments of part #2.

Examples #2, Query #1 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Steps to take? Select the shipments of part #2. Link these shipments with the supplier information (to get the supplier names).

Examples #2, Query #1 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Steps to take? Select the shipments of part #2. Link these shipments with the supplier information (to get the supplier names). Extract the supplier names.

Examples #2, Query #1 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Step 1: Select the shipments of Part #2.

Examples #2, Query #1 Πsupp-name(σpart-id=‘2’(supplies) supplier) Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Step 1: Select the shipments of Part #2. Πsupp-name(σpart-id=‘2’(supplies) supplier)

Examples #2, Query #1 Πsupp-name(σpart-id=‘2’(supplies) supplier) Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Step 2: Link these shipments with the supplier information (to get the supplier names). Πsupp-name(σpart-id=‘2’(supplies) supplier)

Examples #2, Query #1 Πsupp-name(σpart-id=‘2’(supplies) supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Step 2: Link these shipments with the supplier information (to get the supplier names). Πsupp-name(σpart-id=‘2’(supplies) supplier

Examples #2, Query #1 Πsupp-name(σpart-id=‘2’(supplies) supplier) Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Step 3: Extract the supplier names. Πsupp-name(σpart-id=‘2’(supplies) supplier)

Examples #2, Query #1 Πsupp-name(σpart-id=‘2’(supplies) supplier) Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Step 3: Extract the supplier names. Πsupp-name(σpart-id=‘2’(supplies) supplier)

Examples #2, Query #1 Πsupp-name(σpart-id=‘2’(supplies) supplier) Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #1: Retrieve the names of suppliers that have shipments of part #2. Πsupp-name(σpart-id=‘2’(supplies) supplier)

Examples #2, Query #2 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers.

Examples #2, Query #2 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers.

Examples #2, Query #2 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers.

Examples #2, Query #2 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers.

Examples #2, Query #2 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers.

Examples #2, Query #2 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers.

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 1: Extract all parts that are red. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies)))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 1: Extract all parts that are red. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies)))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 2: Get the part numbers for those red parts. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies)))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 2: Get the part numbers for those red parts. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies)))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 3: Extract all shipments of those red parts. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies)))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 3: Extract all shipments of those red parts. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies)))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 4: Get the suppliers of those shipments. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies)))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 4: Get the suppliers of those shipments. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies)))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Step 5: Get the supplier names of those suppliers. Projection of supp-id may not be needed. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies))

Examples #2, Query #2 Πsupp-name(supplier Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #2: Retrieve the names of suppliers that have shipments of at least one ‘red’ part. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers. Πsupp-name(supplier Πsupp-id(Πpart-id(σcolor=‘red’(parts)) supplies))

Examples #2, Query #3 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Extract all parts that are red. Get the part numbers for those red parts. Extract all shipments of those red parts. Get the suppliers of those shipments. Get the supplier names of those suppliers.

Examples #2, Query #3 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Get the part numbers for those red parts. Get the suppliers of those shipments.

Examples #2, Query #3 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Use those supplier-id’s to get their names. Get the suppliers of those shipments.

Examples #2, Query #3 Πsupp-name((Πsupp-id,part-id(supplies)  Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Use those supplier-id’s to get their names. Get the suppliers of those shipments. Step 1: Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Πsupp-name((Πsupp-id,part-id(supplies)  Πpart-id(part)) supplier)

Examples #2, Query #3 Πsupp-name((Πsupp-id,part-id(supplies)  Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Use those supplier-id’s to get their names. Get the suppliers of those shipments. Step 1: Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Πsupp-name((Πsupp-id,part-id(supplies)  Πpart-id(part)) supplier)

Examples #2, Query #3 Πsupp-name((Πsupp-id,part-id(supplies)  Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Use those supplier-id’s to get their names. Get the suppliers of those shipments. Step 2: Use those supplier-id’s to get their names. Πsupp-name((Πsupp-id,part-id(supplies)  Πpart-id(part)) supplier)

Examples #2, Query #3 Πsupp-name((Πsupp-id,part-id(supplies)  Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Use those supplier-id’s to get their names. Get the suppliers of those shipments. Step 2: Use those supplier-id’s to get their names. Πsupp-name((Πsupp-id,part-id(supplies)  Πpart-id(part)) supplier)

Examples #2, Query #3 Πsupp-name((Πsupp-id,part-id(supplies)  Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Use those supplier-id’s to get their names. Get the suppliers of those shipments. Step 2: Use those supplier-id’s to get their names. Πsupp-name((Πsupp-id,part-id(supplies)  Πpart-id(part)) supplier)

Examples #2, Query #3 Πsupp-name((Πsupp-id,part-id(supplies)  Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #3: Give the names of suppliers that have shipments of all the parts. Steps to take? Division between the shipments and all the part-id’s (this will give us supplier-id’s of such suppliers). Use those supplier-id’s to get their names. Get the suppliers of those shipments. Πsupp-name((Πsupp-id,part-id(supplies)  Πpart-id(part)) supplier)

Examples #2, Query #4 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments.

Examples #2, Query #4 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments.

Examples #2, Query #4 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments.

Examples #2, Query #4 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments.

Examples #2, Query #4 Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Step 1: Extract all suppliers that do ship part #2.

Examples #2, Query #4 Πsupp-name(supplier (Πsupp-id(supplies) – Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Step 1: Extract all suppliers that do ship part #2. Πsupp-name(supplier (Πsupp-id(supplies) – Πsupp-id(σpart-id=‘2’(supplies))))

Examples #2, Query #4 Πsupp-name(supplier (Πsupp-id(supplies) – Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Step 1: Extract all suppliers that do ship part #2. Πsupp-name(supplier (Πsupp-id(supplies) – Πsupp-id(σpart-id=‘2’(supplies))))

Examples #2, Query #4 Πsupp-name(supplier (Πsupp-id(supplies) – Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Step 2: Using those, compute the ones that do not ship part #2. Πsupp-name(supplier (Πsupp-id(supplies) – Πsupp-id(σpart-id=‘2’(supplies))))

Examples #2, Query #4 Πsupp-name(supplier (Πsupp-id(supplier) – Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Step 2: Using those, compute the ones that do not ship part #2. Recall that the schemes have to be the same. That’s why we project only the supp-id’s. Πsupp-name(supplier (Πsupp-id(supplier) – Πsupp-id(σpart-id=‘2’(supplies))))

Examples #2, Query #4 Πsupp-name(supplier (Πsupp-id(supplier) – Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Step 3: From those suppliers, get their names. Recall that the schemes have to be the same. That’s why we project only the supp-id’s. Πsupp-name(supplier (Πsupp-id(supplier) – Πsupp-id(σpart-id=‘2’(supplies))))

Examples #2, Query #4 Πsupp-name(supplier (Πsupp-id(supplier) – Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Step 3: From those suppliers, get their names. Recall that the schemes have to be the same. That’s why we project only the supp-id’s. Πsupp-name(supplier (Πsupp-id(supplier) – Πsupp-id(σpart-id=‘2’(supplies)))))

Examples #2, Query #4 Πsupp-name(supplier (Πsupp-id(supplier) – Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Step 3: From those suppliers, get their names. Πsupp-name(supplier (Πsupp-id(supplier) – Πsupp-id(σpart-id=‘2’(supplies))))

Examples #2, Query #4 Πsupp-name(supplier (Πsupp-id(supplier) – Relational Schema Part(part-id, part-name, color) Supplier(supp-id,supp-name,address) Supplies(supp-id,part-id,quantity) Query #4: Names of suppliers that do not have shipments of part #2. Steps to take? Extract all suppliers that do ship part #2. Using those, compute the ones that do not ship part #2. From those suppliers, get their names. Get the suppliers of those shipments. Πsupp-name(supplier (Πsupp-id(supplier) – Πsupp-id(σpart-id=‘2’(supplies))))

Examples #3 d-name d-city ba-name ba-city Frequents Drinker Bar Likes Serves All of them are many to many. Beer be-name type

Examples #3 d-name d-city ba-name ba-city Frequents Drinker Bar Likes Serves Relational Schema: Drinker(d-name,d-city) Bar(ba-name,ba-city) Beer(be-name,type) One relation for each entity set Beer be-name type

Examples #3 d-name d-city ba-name ba-city Frequents Drinker Bar Likes Serves Relational Schema: Drinker(d-name,d-city) Bar(ba-name,ba-city) Beer(be-name,type) Frequents(d-name,ba-name) Serves(ba-name,be-name) Likes(d-name,be-name) One relation for each relationship set Beer be-name type

Example #3, Query #1 Relational Schema: DRINKER(d-name,d-city) BAR(ba-name,ba-city) BEER(be-name,type) FREQUENTS(d-name,ba-name) SERVES(ba-name,be-name) LIKES(d-name,be-name) Query #1: Which bars serve a beer that Joe likes?