Schema BankWorld Customer(C_Name, C_Street, C_City) Depositor(Account_#, C_Name) Loan(Loan_#, B_Name, Amount) Borrower(C_Name, Loan_#)

Slides:



Advertisements
Similar presentations
SQL: The Query Language Part 2
Advertisements

SQL: The Query Language Part 1 R &G - Chapter 5 Life is just a bowl of queries. -Anon (not Forrest Gump)
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra) Query Formulation Exercise.
Relational Algebra Chapter 4, Part A
SQL: Queries.
TURKISH STATISTICAL INSTITUTE 1 /34 SQL FUNDEMANTALS (Muscat, Oman)
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.
RELATIONAL CALCULUS Rohit Khokher. INTRODUCTION Relational calculus is a formal query language where the queries are expressed as variables and formulas.
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.
SQL (2).
SQL Review.
FALL 2004CENG 351 File Structures and Data Management1 SQL: Structured Query Language Chapter 5.
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.
Chapter 5 Other Relational Languages By Cui, Can B.
Introduction to Database Systems 1 Relational Algebra Relational Model: Topic 3.
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 Algebra. Relational Query Languages n Query = “retrieval program” n Language examples: ù Theoretical : 1. Relational Algebra 2. Relational.
Introduction to Database Systems 1 Relational Calculus Relational Model : Topic 2.
1 Advanced SQL. 2 Consider the following relations: –pupil (pupil_name, address, class, birthyear) –subject (subject_name, class, teacher) –grades (pupil_name,
Relational Algebra.
Chapter 5.  Data Manipulation Language (DML): subset of SQL which allows users to create queries and to insert, delete and modify rows.  Data Definition.
Relational algebra SHIRAJ MOHAMED M | MIS 1. Relational algebra Notation SHIRAJ MOHAMED M | MIS 2.
SQL – Introduction  Standard DML/DDL for relational DB’s  DML = “Data Manipulation Language” (queries, updates)  DDL = “Data Definition Language” (create.
SQL Examples CS3754 Class Note 11 CS3754 Class Note 11, John Shieh,
SQL 2 Introduction Structured Query Language (SQL): the most widely used commercial relational database language Originally.
Database Management Systems,1 Relational Calculus.
ICS 321 Fall 2009 SQL: Queries, Constraints, Triggers Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 9/8/20091Lipyeow.
CS 370 Database Systems Lecture 11 Relational Algebra.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra.
More SQL Today:  Nested Queries  More SQL Nested Queries in SQL  Queries containing other queries  Inner query:  Can appear in FROM or WHERE clause.
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.
CMPT 258 Database Systems Relational Algebra (Chapter 4)
CMPT 258 Database Systems SQL Queries (Chapter 5).
Assertions and Triggers in SQL
SQL II.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 5 SQL.
1 SQL: The Query Language (Part II). 2 Expressions and Strings v Illustrates use of arithmetic expressions and string pattern matching: Find triples (of.
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
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.
SQL Exercises. 1) Names of suppliers. Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)
Relational Calculus Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Relational Algebra & Calculus
Structured Query Language
Database Systems (資料庫系統)
Session 3 Welcome: To session 3-the fourth learning sequence
Basic SQL Queries Go over example queries, like 10 > ALL.
Structured Query Language (Data Manipulation Language)
© פרופ' יהושע שגיב, האוניברסיטה העברית
CS4432: Database Systems II
01/31/11 SQL Examples Edited by John Shieh CS3754 Classnote #10.
COP Introduction to Database Structures
Relational Algebra.
Database Applications (15-415) SQL-Part II Lecture 9, February 04, 2018 Mohammad Hammoud.
Database Systems 10/13/2010 Lecture #4.
CS 405G: Introduction to Database Systems
CSCI 6315 Applied Database Systems – Exercise (3)
LECTURE 3: Relational Algebra
Relational Calculus.
Schema Used in Examples
Relational Algebra & Calculus
Example: Banking Database
CS 405G: Introduction to Database Systems
Presentation transcript:

Schema BankWorld Customer(C_Name, C_Street, C_City) Depositor(Account_#, C_Name) Loan(Loan_#, B_Name, Amount) Borrower(C_Name, Loan_#)

Exercise: Select tuples of the loan relation where the branch name is “UTD” Find all tuples in which the amount of lent is more than $1200 Find those tuples pertaining to loans of more than $1200 made by “UTD” branch List all loan numbers and the amount of loan Find the names of all customers who live in “Dallas” Find the names of all bank customers who have either an account or a loan or both Find the name of all customers of the bank who have an account but not a loan Find the name of all customers who have both a loan and an account

Express the following query using SQL: 1. Sailors X Reserves 2. Sailors  sailors.id < reserves.id Reserves 3. Sailors  sailors.id = reserves.id Reserves 4. Sailors  Reserves 5. Find the names of sailors who have reserved boat Find the names of sailors who have reserved a red boat 7. Find the colors of boats reserved by Dustin 8. Find the names of sailors who have reserved at least one boat 9. Find the names of sailors who have reserved a red or a green boat 10. Find the names of sailors who have reserved both a red and a green boat 11. Find the names of sailors with age over 20 who have not reserved a red boat 12. Find the names of sailors who have reserved at least two boats 13. Find the sids of all sailors who have reserved red boats but not green boats 14. Find sailors whose rating is better than some sailor called Smith 15. Find sailors whose rating is better than every sailor called Smith 16. Find the names of sailors who have not reserved a red boat 17. Find the average age of all sailors 18. Find the average age of sailors with a rating of Find the name and age of the oldest sailor 20. Count the # of sailors 21. Find the names of sailors who are older than the oldest sailor with a rating Find the age of the youngest sailor for each rating level 23. Find the age of the youngest sailor who is eligible to vote ( i.e., at least 18 years old) for each rating level with at least two such sailors 24. For each red boat, find the number of reservations for this boat 25. Find the average age of sailors for each rating level that has at least two sailors Find the average age of sailors who are of voting age (i.e., at least 18 years old) for each rating level that has at least two sailors