Chapter 4 Practice Problem Solutions. A list (Bno, Street, Area,Tel_No, Fax_No) of branches located in Bay Area Branch (Bno, Street, Area, City, Pcode,

Slides:



Advertisements
Similar presentations
SQL. More than 100 DBMS support SQL –Used by DBAs and application programmers –Structured Query Language or SEQUEL –ORACLE-> relation database based on.
Advertisements

Relational Algebra and Relational Calculus
RELATIONAL DATABASES. Relational data Structure RELATION: Table with columns and rows ATTRIBUTE: Column of a relation DOMAIN: Set of allowable values.
Assignment Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the.
CSC271 Database Systems Lecture # 11.
Chapter 3 CIS 458 Sungchul Hong
RELATIONAL ALGEBRA Lecture Relational Algebra Operations to manipulate relations. Used to specify retrieval requests (queries). Query results in.
CSC271 Database Systems Lecture # 13. Summary: Previous Lecture  Grouping through GROUP BY clause  Restricted groupings  Subqueries  Multi-Table queries.
Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_NO) Staff (Sno, FName, LName, Address, Tel_No, Position, Sex, DOB, Salary, NIN, Bno) Property_for_Rent.
Chapter 6 SQL. Agenda Data Definition Language (DDL) Access Control.
1 Minggu 3, Pertemuan 5 Relational Algebra (Cont.) Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
1 Design Methodology A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the process of design.
1 CS 3630 Database Design and Implementation. 2 Final Exam 7:00 – 8:52 PM, Thursday, May 16 Section 1: Ull 009 Section 2: Ull Points –50 points.
Chapter 5 SQL. Agenda Data Manipulation Language (DML) –SELECT –Union compatible operations –Update database.
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
Database Management COP4540, SCS, FIU Database Modeling Using the Entity-Relationship Model (Chapter 3)
Chapter 6 SQL. Agenda Data Definition Language (DDL) Access Control.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Introduction to Databases. Case Example: File based Processing Real Estate Agent’s office Property for sale or rent Potential Buyer/renter Staff/employees.
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
1 Test1 N = {n: n is an integer and n  0} X = {x: x = n + 5, where n  N} Y = {y: y = 7 * n - 1, where n  N} List the three smallest elements of each.
Agenda TMA01 M876 Block 3 – Using SQL Structured Query Language - SQL A non-procedural language to –Create database and relation structures. –Perform.
CSC271 Database Systems Lecture # 12. Summary: Previous Lecture  Row selection using WHERE clause  WHERE clause and search conditions  Sorting results.
Relational Algebra Chapter 4 CIS 458 Sungchul Hong.
Chapter 7 SQL: Data Manipulation Chapter#6 in the text book Pearson Education © 2009.
B. Information Technology (Hons.) CMPB245: Database Design Logical Database Design.
SQL Data Manipulation II Chapter 5 CIS 458 Sungchul Hong.
1 General Form of the SELECT Statement SELECT [DISTINCT | ALL {* | col_expr [AS new_name] [,…]} FROMtable_name [,…] [,…] [WHERE condition] [GROUP BY col_list]
Chapter 5 SQL Data Manipulation Language Chapter 5 in Textbook.
Bayu Adhi Tama, ST., MTI. Introduction Relational algebra and relational calculus are formal languages associated with the relational.
Advanced Database Systems
CS 3630 Database Design and Implementation. 2 DreamHome Branch (branchNo, street, city, state, zipcode, phone1, phone2, phone3) Staff (staffNo, firstName,
1 E-R Model (II) Keys To identify records in a table Candidate Key Primary Key Alternate Key Composite Key.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
Chapter 7 SQL: Data Manipulation Chapter #6 in the textbook Pearson Education © 2009.
1 Chapter 17 Methodology - Local Logical Database Design.
CS 3630 Database Design and Implementation. 2 Functions y = f(x) x1 = x2  f(x1) = f(x2) Same x value, then same function value. Yes, it’s a function!
CS 3630 Database Design and Implementation. Database Schema Branch (Bno…) Staff (Sno…Bno) Owner (Ono…) PropertyForRent (Pno…Ono) Renter (Rno…) Viewing.
Chapter 5 Relational Algebra and Relational Calculus Pearson Education © 2009.
IST 210 SQL Todd Bacastow IST 210: Organization of Data.
Chapter 8 Introduction to SQL
Chapter 5 Relational Algebra Pearson Education © 2014.
1 Geog 357 – Introduction to GIS The Relational Language.
CSC271 Database Systems Lecture # 8. Summary: Previous Lecture  Relation algebra and operations  Selection (Restriction), projection  Union, set difference,
Schema Conversion Create a table for each entity –1:1 choose one side and put a foreign key –1:* put a foreign key in many side –*:* create a table for.
1 Pertemuan > > Matakuliah: >/ > Tahun: > Versi: >
CSC271 Database Systems Lecture # 7. Summary: Previous Lecture  Relational keys  Integrity constraints  Views.
Branch (Bno, Area, City, Pcode) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for Rent (Pno, Area, City, Type, Rooms, Rent, Ono,
2 Database Design Chapter Operations of the Relational Model Updates: changes the database’s state. Insert Delete Update/modify Retrievals: does.
Quiz Where to Store Attributes of Relationship Staff (1) Interviews (0..*) Client Attributes: date, time, comment Staff (StaffNo, …) PK: StaffNo.
IST 210 More SQL Todd Bacastow IST 210: Organization of Data.
LECTURE THREE RELATIONAL ALGEBRA 11. Objectives  Meaning of the term relational completeness.  How to form queries in relational algebra. 22Relational.
Chapter 4 Relational Algebra Chapter 4 in Textbook.
Teacher Workshop Database Design Pearson Education © 2014.
Relational Algebra Lecture 2.
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
Data Manipulation Language
CS 3630 Database Design and Implementation
The Relational Database Model
Chapter Name SQL: Data Manipulation Chapter #6 in the textbook
Chapter Name SQL: Data Manipulation Chapter #6 in the textbook
Conceptual Database Design
Chapter Name SQL: Data Manipulation
Quiz 1 1. Given two sets S = {3, 5, 7} and T = {2, 4, 6}. List all elements of the following set: {(s, t) | (s, t)  S  T and s + t = 9} Result (3, 6)
CS 3630 Database Design and Implementation
SQL – Data Manipulation
Chapter Name SQL: Data Manipulation
The Relational Algebra
Chapter Name SQL: Data Manipulation Transparencies JOINS
Presentation transcript:

Chapter 4 Practice Problem Solutions

A list (Bno, Street, Area,Tel_No, Fax_No) of branches located in Bay Area Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A list (Bno, Street, Area,Tel_No, Fax_No) of branches located in Bay Area Select Branch where Area = ‘Bay Area’ giving T1 Project T1 over (Bno, Street, Area,Tel_No, Fax_NO) giving T2

A list (Pno, Street, Area, City) of properties for rent with 4 bedrooms or less than $1,000 per month rent Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A list (Pno, Street, Area, City) of properties for rent with 4 bedrooms or less than $1,000 per month rent Select Property_for_Rent where Rooms = 4 or Rent < 1000 giving T1 Project T1 over (Pno, Street, Area, City) giving T2

A list (Sno, FName, LName) of female mangers with salary between one to two million dollars Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A list (Sno, FName, LName) of female mangers with salary between one to two million dollars Select Staff where Sex = ‘F’ giving T1 Select T1 where Salary >= 1M and Salary <= 2M giving T2 Select T2 where Position = ‘manager’ giving T3 Project T3 over (Sno, FName, LName) giving T4

A list (Pno, Street, Area, City) of properties for rent located in SF, LA, NY, or DC Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A list (Pno, Street, Area, City) of properties for rent located in SF, LA, NY, or DC Project Property_for_Rent over (Pno, Street, Area, City) giving T1 Select T1 where City = ‘SF’ and City = ‘LA’ and City = ‘NY’ and City = ‘DC’ giving T2

A list (Pno, Street, Area, City) of properties for rent located in SF, LA, NY, or DC Project Property_for_Rent over (Pno, Street, Area, City) giving T1 Select T1 where City = ‘SF’ giving T2 Select T1 where City = ‘LA’ giving T3 Select T1 where City = ‘NY’ giving T4 Select T1 where City = ‘DC’ giving T5 T2 Union T3 giving T6 T6 Union T4 giving T7 T7 Union T5 giving T8

A list (Pno, Street, Area, City) of properties for rent managed by John Dow and owned by Sue Lee Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A list (Pno, Street, Area, City) of properties for rent managed by John Dow and owned by Sue Lee Property_for_Rent join Owner where Property_for_Rent.Ono = Owner.Ono giving T1 T1 join Staff where T1.Sno = Staff.Sno giving T2 Select T2 where Staff.Fname = ‘John’ and Staff.Lname = ‘Dow’ giving T3 Select T3 where Owner.Fname = ‘Sue’ and Owner.Lname = ‘Lee’ giving T4 Project T4 over (Pno, Street, Area, City) giving T8

A list (Sno, FName, LName) of staffs who do not supervise any property for rent Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A list (Sno, FName, LName) of staffs who do not supervise any property for rent Staff leftouterjoin Property_for_Rent where Staff.Sno = Property_for_Rent.Sno giving T1 Select T1 where Pno = null giving T2 Project T2 over (Sno, FName, LName) giving T3

A list (Sno, FName, LName) of staffs who do not supervise any property for rent Property_for_Rent rightouterjoin Staff where Staff.Sno = Property_for_Rent.Sno giving T1 Select T1 where Property_for_Rent.Pno = null giving T2 Project T2 over (Sno, FName, LName) giving T3

A list (Sno, FName, LName) of staffs who do not supervise any property for rent Property_for_Rent fullouterjoin Staff where Staff.Sno = Property_for_Rent.Sno giving T1 Select T1 where Property_for_Rent.Pno = null giving T2 Project T2 over (Sno, FName, LName) giving T3

A list (Rno, Fname, Lname) of renters who have not looked any property for rent Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A list (Rno, Fname, Lname) of renters who have not looked any property for rent Renter leftouterjoin Viewing where Renter.Rno = Viewing.Rno giving T1 Select T1 where Pno = null giving T2 Project T2 over (Rno, Fname, Lname) giving T3

A list (Rno, Fname, Lname) of renters who have not looked any property for rent Viewing rightouterjoin Renter where Renter.Rno = Viewing.Rno giving T1 Select T1 where Pno = null giving T2 Project T2 over (Rno, Fname, Lname) giving T3

A list (Rno, Fname, Lname) of renters who have not looked any property for rent Viewing fullouterjoin Renter where Renter.Rno = Viewing.Rno giving T1 Select T1 where Pno = null giving T2 Project T2 over (Rno, Fname, Lname) giving T3

A staff list (Sno, FName, LName) of staffs who supervise a property for rent Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A staff list (Sno, FName, LName) of staffs who supervise a property for rent Staff join Property_for_Rent where Staff.Sno = Property_for_Rent.Sno giving T1 Project T1 over (Sno, FName, LName) giving T2

A renter viewing list (Rno, Fname, Lname) of renters who have looked a property for rent Branch (Bno, Street, Area, City, Pcode, Tel_No, Fax_No) Staff (Sno, FName, LName, Position, Sex, DOB, Salary, Bno) Property_for_Rent (Pno, Street, Area, City, Type, Rooms, Rent, Ono, Sno, Bno) Renter (Rno, FName, LName, Pref_Type, Max_Rent) Owner ( Ono, FName, LName) Viewing (Rno, Pno, Date, Comment)

A renter viewing list (Rno, Fname, Lname) of renters who have looked a property for rent Renter join Viewing where Renter.Rno = Viewing.Rno giving T1 Project T1 over (Rno, Fname, Lname) giving T2