Exercises Find the names of sailors who’ve reserved boat #103 { N |  S  Sailors (S.name = N.name   R  Reserves(S.sid = R.sid  R.bid = 103)) }

Slides:



Advertisements
Similar presentations
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra) Query Formulation Exercise.
Advertisements

1 TRC vs DRC 한욱신. 2 Queries in TRC and DRC  TRC Q = {t| f(t)} where t is a (free) tuple variable and f(t) is a well-formed formula  DRC.
Chapter (7): Advanced SQL
Review Session ER and Relational –ER  Relational –Constraints, Weak Entities, Aggregation, ISA Relational Algebra  Relational Calculus –Selections/Projections/Joins/Division.
Introduction to Database Systems 1 SQL: The Query Language Relation Model : Topic 4.
1 SQL: Structured Query Language (‘Sequel’) Chapter 5.
1 Relational Calculus Chapter 4 – Part II. 2 Formal Relational Query Languages  Two mathematical Query Languages form the basis for “real” languages.
SQL: The Query Language Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein and etc for some slides.
CS 405G: Introduction to Database Systems
CMPT 258 Database Systems SQL: Queries, Constraints, Triggers (Chapter 5) Part II home.manhattan.edu/~tina.tian.
1 SQL: Structured Query Language (‘Sequel’) Chapter 5.
SQL 2 – The Sequel R&G, Chapter 5 Lecture 10. Administrivia Homework 2 assignment now available –Due a week from Sunday Midterm exam will be evening of.
1 SQL (Simple Query Language). 2 Query Components A query can contain the following clauses –select –from –where –group by –having –order by Only select.
FALL 2004CENG 351 File Structures and Data Management1 SQL: Structured Query Language Chapter 5.
Relational Calculus. Another Theoretical QL-Relational Calculus n Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus.
Relational Calculus CS 186, Spring 2007, Lecture 6 R&G, Chapter 4 Mary Roth   We will occasionally use this arrow notation unless there is danger of.
1 Table Alteration. 2 Altering Tables Table definition can be altered after its creation –Adding columns –Changing columns’ definition –Dropping columns.
1 Rewriting Minus Queries Using Not In SELECT S.sname FROM Sailors S, Boats B, Reserves R WHERE S.sid = R.sid and R.bid = B.bid and B.color = ‘red’ MINUS.
1 The Oracle Database System Querying the Data Database Course The Hebrew University of Jerusalem.
Exercises ReservesSailorsBoats Find names of sailors who’ve reserved boat #103 Basic operations: Selection ( σ ) gives a subset of rows. Projection ( π.
1 SQL: Structured Query Language Chapter 5. 2 SQL and Relational Calculus relationalcalculusAlthough relational algebra is useful in the analysis of query.
1 Rewriting Intersect Queries Using In SELECT S.sid FROM Sailors S, Boats B, Reserves R WHERE S.sid = R.sid and R.bid = B.bid and B.color = ‘red’ INTERSECT.
Relational Calculus R&G, Chapter 4   We will occasionally use this arrow notation unless there is danger of no confusion. Ronald Graham Elements of Ramsey.
Relational Calculus CS 186, Fall 2003, Lecture 6 R&G, Chapter 4   We will occasionally use this arrow notation unless there is danger of no confusion.
1 Advanced SQL. 2 Consider the following relations: –pupil (pupil_name, address, class, birthyear) –subject (subject_name, class, teacher) –grades (pupil_name,
Introduction to SQL Basics; Christoph F. Eick & R. Ramakrishnan and J. Gehrke 1 Introduction to SQL Basics --- SQL in 45 Minutes Chapter 5.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L6_SQL(1) 1 SQL: Queries, Constraints, Triggers Chapter 5 – Part 1.
SQL Part I: Standard Queries. COMP-421: Database Systems - SQL Queries I 2 Example Instances sid sname rating age 22 debby debby lilly.
SQL Examples CS3754 Class Note 11 CS3754 Class Note 11, John Shieh,
Relational Calculus R&G, Chapter 4. Relational Calculus Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus (DRC). Calculus.
Relational Calculus CS 186, Spring 2005, Lecture 9 R&G, Chapter 4   We will occasionally use this arrow notation unless there is danger of no confusion.
The Oracle Database System. Connecting to the Database At the command line prompt, write: sqlplus In the beginning your password.
1 Copyright © Kyu-Young Whang Relational Calculus Chapter 4, Part B.
CMPT 258 Database Systems SQL Queries (Chapter 5).
1 SQL: The Query Language (Part II). 2 Expressions and Strings v Illustrates use of arithmetic expressions and string pattern matching: Find triples (of.
1 SQL: Structured Query Language (‘Sequel’) Chapter 5.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2007.
CSCI 4333 Database Design and Implementation – Exercise (2) Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
Relational Calculus Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
SQL: The Query Language Part 1 R &G - Chapter 5 The important thing is not to stop questioning. Albert Einstein.
1 SQL: The Query Language. 2 Example Instances R1 S1 S2 v We will use these instances of the Sailors and Reserves relations in our examples. v If the.
Spring 2011 ITCS3160: Database Design and Implementation Hands-on Learning.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Basic SQL Queries.
1 CS122A: Introduction to Data Management Lecture 9 SQL II: Nested Queries, Aggregation, Grouping Instructor: Chen Li.
1 SQL: The Query Language. 2 Example Instances R1 S1 S2 v We will use these instances of the Sailors and Reserves relations in our examples.
DataBase - Check 01 DataBase 2 nd year Computer Science & Engineer 1.
Relational Calculus Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Basic SQL Queries Go over example queries, like 10 > ALL.
COP Introduction to Database Structures
© פרופ' יהושע שגיב, האוניברסיטה העברית
01/31/11 SQL Examples Edited by John Shieh CS3754 Classnote #10.
SQL The Query Language R & G - Chapter 5
CS222P: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Database Systems October 14, 2009 Lecture #5.
Basic SQL Lecture 6 Fall
Introduction to Database Systems
Database Applications (15-415) SQL-Part II Lecture 9, February 04, 2018 Mohammad Hammoud.
CS 186, Spring 2007, Lecture 6 R&G, Chapter 4 Mary Roth
CS 405G: Introduction to Database Systems
CSCI 6315 Applied Database Systems – Exercise (3)
Relational Calculus.
SQL: The Query Language Part 1
קורס קבצים ובסיסי נתונים
SQL: Structured Query Language
Textbook Chapter 9 (incl. example queries at end)
CS 186, Fall 2002, Lecture 8 R&G, Chapter 4
CS 186, Spring 2007, Lecture 6 R&G, Chapter 4 Mary Roth
CS222: Principles of Data Management Lecture #15 Query Optimization (System-R) Instructor: Chen Li.
Relational Calculus Chapter 4 – Part II.
Presentation transcript:

Exercises Find the names of sailors who’ve reserved boat #103 { N |  S  Sailors (S.name = N.name   R  Reserves(S.sid = R.sid  R.bid = 103)) }

Exercises Find the names of sailors who’ve reserved any red boat { N |  S  Sailors (S.name = N.name   R  Reserves (S.sid = R.sid   B  Boats(B.color = “Red”  B.bid = R.bid))) }

Exercises Find sailors who’ve reserved a red boat or a green boat { S | S  Sailors  (  R  Reserves (S.sid = R.sid   B  Boats(B.bid = R.bid  (B.color = “Red”   B.color = “Green” )))) }

Exercises Find sailors who’ve reserved a red boat and a green boat { S | S  Sailors  ((  R  Reserves (S.sid = R.sid   B  Boats(B.color = “Red”  B.bid = R.bid)))  (  R  Reserves (S.sid = R.sid   B  Boats(B.color = “Green”  B.bid = R.bid)))) }

Exercises Find sailors who’ve reserved all red boats {S | S  Sailors   B  Boats(B.color = ‘red’   R(R  Reserves  S.sid = R.sid  B.bid = R.bid))} {S | S  Sailors   B  Boats (B.color  ‘red’   R(R  Reserves  S.sid = R.sid  B.bid = R.bid))} Alternatively ….(remember that a  b is the same as ¬a  b)