CSCI 4333 Database Design and Implementation – Exercise (2) Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539

Slides:



Advertisements
Similar presentations
SQL: The Query Language Part 1 R &G - Chapter 5 Life is just a bowl of queries. -Anon (not Forrest Gump)
Advertisements

Complex Integrity Constraints in SQL. Constraints over a Single Table Table Constraint: Create TABLE Sailors (sid INTEGER, sname CHAR(10), rating INTEGER,
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra) Query Formulation Exercise.
SQL: Queries.
1 Database Systems 10.8, 2008 Lecture #4. 2 Course Administration Assignment #1 is due next Wed (outside 336/338). Course slides will now have black background.
Relational Calculus   Logic, like whiskey, loses its beneficial effect when taken in too large quantities. --Lord Dunsany.
1 Advanced SQL Queries. 2 Example Tables Used Reserves sidbidday /10/04 11/12/04 Sailors sidsnameratingage Dustin Lubber Rusty.
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
Relational Algebra Rohit Khokher. Relational Algebra Set Oriented Operations UnionIntersectionDifference Cartesian Product Relation Oriented Operations.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A Modified by Donghui Zhang.
Schema BankWorld Customer(C_Name, C_Street, C_City) Depositor(Account_#, C_Name) Loan(Loan_#, B_Name, Amount) Borrower(C_Name, Loan_#)
INFS614, Fall 08 1 Relational Algebra Lecture 4. INFS614, Fall 08 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of.
SQL and Relational Algebra Zaki Malik September 02, 2008.
1 Relational Algebra & Calculus. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
CMPT 258 Database Systems SQL: Queries, Constraints, Triggers (Chapter 5) Part II home.manhattan.edu/~tina.tian.
FALL 2004CENG 351 File Structures and Data Managemnet1 Relational Algebra.
1 Relational Algebra. 2 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
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 ( π.
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)) }
CSCD343- Introduction to databases- A. Vaisman1 Relational Algebra.
Relational Algebra.
CSCI 4333 Database Design and Implementation – Exercise (3) Xiang Lian The University of Texas – Pan American Edinburg, TX
Data Definition After this lecture, you should be able to:
ICS 321 Fall 2009 SQL: Queries, Constraints, Triggers Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 9/8/20091Lipyeow.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra.
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra)
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 4 Relational Algebra.
CSCD34-Data Management Systems - A. Vaisman1 Relational Algebra.
CSCI 4333 Database Design and Implementation – Exercise (5) Xiang Lian The University of Texas – Pan American Edinburg, TX
CMPT 258 Database Systems Relational Algebra (Chapter 4)
CMPT 258 Database Systems SQL Queries (Chapter 5).
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2007.
SQL: The Query Language Part 1 R &G - Chapter 5 The important thing is not to stop questioning. Albert Einstein.
CSCI 4333 Database Design and Implementation – Exercise (1) Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
DataBase - Check 01 DataBase 2 nd year Computer Science & Engineer 1.
SQL Exercises. 1) Names of suppliers. Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)
CSCI 4333 Database Design and Implementation – Exercise (5)
Relational Calculus Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Relational Algebra & Calculus
Database Systems (資料庫系統)
© פרופ' יהושע שגיב, האוניברסיטה העברית
CS4432: Database Systems II
COP Introduction to Database Structures
Relational Algebra Chapter 4, Part A
CSCI 6315 Applied Database Systems – Exercise (1)
Database Systems 10/13/2010 Lecture #4.
Relational Algebra.
CS 405G: Introduction to Database Systems
CSCI 6315 Applied Database Systems – Exercise (3)
CSCI 4333 Database Design and Implementation – Exercise (3)
Relational Calculus.
SQL: The Query Language Part 1
קורס קבצים ובסיסי נתונים
CSCI 3328 Object Oriented Programming in C# Review: Exam I
CSCI 4333 Database Design and Implementation – Exercise (5)
CSCI 6315 Applied Database Systems – Exercise (4)
CSCI 6307 Foundation of Systems – Exercise (1)
CSCI 6315 Applied Database Systems – Exercise (6)
CSCI 4333 Database Design and Implementation – Exercise (4)
실습 4주차.
CENG 351 File Structures and Data Managemnet
Relational Algebra & Calculus
Relational Algebra Chapter 4 - part I.
CSCI 6315 Applied Database Systems – Exercise (5)
CSCI 6307 Foundation of Systems – Exercise (5)
CSCI 4333 Database Design and Implementation – Exercise (1)
Presentation transcript:

CSCI 4333 Database Design and Implementation – Exercise (2) Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX

Relational Algebra and SQL (1) Find ids of sailors who’ve reserved boat with bid 103 – Sailors (sid, sname) – Reserves (sid, bid, date) – Boats (bid, bname, color) 1. Relational algebra (  and  ): 2. SQL: 2

Relational Algebra and SQL (2) Find the names of sailors who’ve reserved boat with bid 103 – Sailors (sid, sname) – Reserves (sid, bid, date) – Boats (bid, bname, color) 1. Relational algebra (  and  ): 2. SQL: 3

Relational Algebra and SQL (3) Find the names of sailors who’ve reserved a red boat – Sailors (sid, sname) – Reserves (sid, bid, date) – Boats (bid, bname, color) 1. Relational algebra (  and  ): 2. SQL: 4

Relational Algebra and SQL (4) Find the names of sailors who’ve reserved a red or a green boat – Sailors (sid, sname) – Reserves (sid, bid, date) – Boats (bid, bname, color) 1. Relational algebra (  and  ): 2. SQL: 5

Relational Algebra and SQL (5) Find the names of sailors who’ve reserved a red and a green boat – Sailors (sid, sname) – Reserves (sid, bid, date) – Boats (bid, bname, color) 1. Relational algebra (  and  ): 2. SQL: 6

Relational Algebra and SQL (6) Find the ids of sailors who have made at least two reservations on the same date – Sailors (sid, sname) – Reserves (sid, bid, date) – Boats (bid, bname, color) 1. Relational algebra (  and  ): 2. SQL: 7

Relational Algebra and SQL (7) 1. Find the ids of sailors who’ve reserved all boats 2. Find the ids of sailors who’ve reserved all red boats 3. Find the names of sailors who’ve reserved all red boats – Sailors (sid, sname) – Reserves (sid, bid, date) – Boats (bid, bname, color) 1. Relational algebra (  and  ): 2. SQL: 8

9