Assignment 2.

Slides:



Advertisements
Similar presentations
CS 3630 Database Design and Implementation. Where Clause and Aggregate Functions -- List all rooms whose price is greater than the -- average room price.
Advertisements

Chapter 4 Hotel (hotelno, hotelname, city)
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Oracle 10g Express. Download Oracle 10g Express Oracle 10g Express Edition: – edition/overview/index.htmlhttp://
1 Assignment 2 Relational Algebra Which tables? What operations? Common attributes? What result (attributes)? Syntax (Standard Notations and Symbols) –Product:
Table Table Table Table Table Table Table Table
CS 3630 Database Design and Implementation. SQL Query Clause Select and From Select * From booking; select hotel_no, guest_no, room_no from booking; select.
Relational Algebra 1 Chapter 5.1 V3.0 Napier University Dr Gordon Russell.
Assignment6-1 Assignment6-2 Due Wednesday, March 13 1.
Chapter 5 SQL. Agenda Data Manipulation Language (DML) –SELECT –Union compatible operations –Update database.
Chapter 6 SQL Homework.
Chapter 5 SQL Homework.
Using SQL to create tables Ways of using Databases.
Create, Insert, Delete, Update. Create Create database Create table Create index – Primary – Secondary.
Project Phase I Phase II Due Monday, April 15 Groups 1.
Chapter 5 SQL. Agenda Data Manipulation Language (DML) –SELECT –Union compatible operations –Update database.
Chapter 5 SQL. Agenda Data Manipulation Language (DML) –SELECT –Union compatible operations –Update database.
IS550: Software requirements engineering
Query Optimization (CB Chapter ) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems: An Application Oriented.
Basic Decimal Concepts 4.2
1 CS 3630 Database Design and Implementation. 2 Sets Foundation of relational database. Basic Operations Power set Mapping.
Week 10 Quiz 9 Answers Group 28 Christine Hallstrom Deena Phadnis.
SQL queries ordering and grouping and joins
SQL - DML. Data Manipulation Language(DML) Are used for managing data: –SELECT retrieve data from the a database –INSERT insert data into a table –UPDATE.
Oracle Command Spool Spool C:\temp\Lab9.lst Select Hotel_no, room_no, type, price From Room Order by Hotel_no; Spool Off.
Chapter 5 SQL: Data Manipulation Thomas Connolly, Carolyn Begg, Database System, A Practical Approach to Design Implementation and Management, 4 th Edition,
SQL introduction 2013.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
CS 3630 Database Design and Implementation. Joins -- For each booking, display the booking -- details with the room type and price Select B.*, rtype,
1 CS 430 Database Theory Winter 2005 Lecture 5: Relational Algebra.
Chapter 7, Section 2. Revenue Management Increase Revenue by: Managing the number of rooms filed Managing the number of discounts offered Booking guests.
INF 280 Database Systems SQL:Join
WBAreaComID Queries Paul Kimsey 3/18/2007. Open Arc Toolbox.
Populating and Querying tables Insert, Update, Delete and View (DML)
CS 3630 Database Design and Implementation. Null Value The value of an attribute could be NULL NOT known at the moment or NOT Applicable Example Cell.
CS 3630 Database Design and Implementation. Base Table and View Base Table Stored on disk View Virtual table Records are not stored on disk Query is stored.
CS 3630 Database Design and Implementation. Where Clause and Aggregate Functions -- List all rooms whose price is greater than the -- average room price.
SQL: Data Manipulation. Objectives Describe the purpose and importance of SQL. Demonstrate how to retrieve data from database using SELECT and: ▫Use compound.
CS 3630 Database Design and Implementation. Joins -- For each booking, display the booking -- details with the room type and price Select B.*, rtype,
CS 3630 Database Design and Implementation. Joins Retrieve data from two or more tables Join Conditions PK and FK (Natural Join) Other attributes (Theta.
Trip to Orlando, Florida Destination: Disney World.
Unit 3 Assignment 1 p2 Daniel Russell. How information is managed To begin with all of the hotels systems what deal with customers bookings and all that.
Multiplication Timed Tests.
Assignements.
CS 3630 Database Design and Implementation
8 people per table, 10 tables in room plus head table
Assignment 2 Relational Algebra Which tables? What operations?
Managing Tables, Data Integrity, Constraints by Adrienne Watt
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
BASIC RESERVATION ACTIVITIES
CS 3630 Database Design and Implementation
Latihan Answer the following questions using the relational schema from the Exercises at the end of Chapter 3: Create the Hotel table using the integrity.
Use the Table of Integrals to evaluate the integral
Solving Compound Inequalities
8 people per table, 10 tables in room plus head table
Stine and Foster Question 16-43
CS 3630 Database Design and Implementation
8 people per table, 10 tables in room plus head table
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
CS 3630 Database Design and Implementation
8 people per table, 10 tables in room plus head table
Higher SDD SQL Practical Tasks.
8 people per table, 10 tables in room plus head table
Extended Registration KS3
Rational Exponents and reducing radicals
Warmup Chapter P Review
Extended Registration KS3
Presentation transcript:

Assignment 2

I a) R (A1, A2) R = {(1, 2), (4, 3), (2, 9), (3, 8)} S (B1, B2, A1) S = {(x, a, 1), (y, b, 1), (z, a, 4)} A1, B2 (A1 < 4 and B1  x (S)) = A1, B2 ( { (y, b, 1) } ) = { (1, b) }

I b) R (A1, A2) R = {(1, 2), (4, 3), (2, 9), (3, 8)} S (B1, B2, A1) S = {(x, a, 1), (y, b, 1), (z, a, 4)} A2, B1 ( R.A1 > S.A1 ( R  S)) = { (3, x), (3, y), (8, x), (8, y), (9, x), (9, y)} R  S (1, 2, x, a, 1) (1, 2, y, b, 1) (1, 2, z, a, 4) (4, 3, x, a, 1) (4, 3, y, b, 1) (4, 3, z, a, 4) (2, 9, x, a, 1) (2, 9, y, b, 1) (2, 9, z, a, 4) (3, 8, x, a, 1) (3, 8, y, b, 1) (3, 8, z, a, 4) R.A1 > S.A1 ( R  S) (4, 3, x, a, 1) (4, 3, y, b, 1) (2, 9, x, a, 1) (2, 9, y, b, 1) (3, 8, x, a, 1) (3, 8, y, b, 1)

I c) R (A1, A2) R = {(1, 2), (4, 3), (2, 9), (3, 8)} S (B1, B2, A1) S = {(x, a, 1), (y, b, 1), (z, a, 4)} R S = { (1, 2, x, a), (1, 2, y, b), (4, 3, z, a)} R  S (1, 2, x, a, 1) (1, 2, y, b, 1) (1, 2, z, a, 4) (4, 3, x, a, 1) (4, 3, y, b, 1) (4, 3, z, a, 4) (2, 9, x, a, 1) (2, 9, y, b, 1) (2, 9, z, a, 4) (3, 8, x, a, 1) (3, 8, y, b, 1) (3, 8, z, a, 4) R.A1 = S.A1 ( R  S) (1, 2, x, a, 1) (1, 2, y, b, 1) (4, 3, z, a, 4)

I d) R (A1, A2) R = {(1, 2), (4, 3), (2, 9), (3, 8)} S (B1, B2, A1) S = {(x, a, 1), (y, b, 1), (z, a, 4)} A2, B1, B2, S.A1 (R S) = { (2, x, a, 1), (2, y, b, 1), (3, z, a, 4)} R  S (1, 2, x, a, 1) (4, 3, x, a, 1) (2, 9, x, a, 1) (3, 8, x, a, 1) (1, 2, y, b, 1) (4, 3, y, b, 1) (2, 9, y, b, 1) (3, 8, y, b, 1) (1, 2, z, a, 4) (4, 3, z, a, 4) (2, 9, z, a, 4) (3, 8, z, a, 4) R S (1, 2, x, a, 1) (1, 2, y, b, 1) (4, 3, z, a, 4)

I e) R (A1, A2) R = {(1, 2), (4, 3), (2, 9), (3, 8)} S (B1, B2, A1) S = {(x, a, 1), (y, b, 1), (z, a, 4)} R S = { (1, 2, x, a), (1, 2, y, b), (4, 3, z, a), (2, 9, null, null), (3, 8, null, null)} R  S (1, 2, x, a, 1) (1, 2, y, b, 1) (1, 2, z, a, 4) (4, 3, x, a, 1) (4, 3, y, b, 1) (4, 3, z, a, 4) (2, 9, x, a, 1) (2, 9, y, b, 1) (2, 9, z, a, 4) (3, 8, x, a, 1) (3, 8, y, b, 1) (3, 8, z, a, 4) R S (1, 2, x, a, 1) (1, 2, y, b, 1) (4, 3, z, a, 4) (2, 9, null, null, null) (3, 8, null, null, null)

Assignment 2: II Relational Algebra Which tables? Join, Out Join, or No Join Common attributes for Join and Out Join? Which records (selection)? What attributes (projection)? Syntax (Standard Notations and Symbols) Product: X Join:

II (a) List all hotels Hotel (hotelNo, hotelName, city) * (Hotel) Use H for Hotel * (H)  hotelNo, hotelName, city (Hotel) hotelNo (Hotel) Incorrect! All attributes when not specified.

b) List all single rooms with a price below $20 per night Room (roomNo, hotelNo, type, price) (type = ‘Single’ and price < 20) (Room)

b) List all single rooms with a price below $20 per night * (  (type = ‘Single’ and price < 20) (Room) ) Projection is NOT Needed! (type = Single and price < 20) (Room)  (type = “Single” and price < 20) (Room)  (type = ‘Single’ and price < $20) (Room)

c) List the name and addresses of all guests Guest (guestNo, guestName, guestAddress) guestName, guestAddress (Guest)

d) List the price and type of all rooms at the Grosvenor Hotel Room (RoomNo, HotelNo, Type, Price) Hotel (HotelNo, hotelName) price, type ( hotelName = ‘Grosvenor’ (Room Hotel)) Common attribute: HotelNo price, type (Room (hotelName = ‘Grosvenor’) (Hotel)) Incorrect! It’s the same as the following:  price, type ((hotelName = ‘Grosvenor’) (Room  Hotel))

e) List all guests currently staying at the Grosvenor Hotel Guest (guestNo, guestName, guestAddress) Hotel (hotelNo, hotelName) Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)  Guest.* ( (fromDate <= CurrentDate and toDate >= CurrentDate) and hotelName = ‘Grosvenor’ (Guest Booking Hotel))

e) List all guests currently staying at the Grosvenor Hotel (fromDate <= CurrentDate and toDate >= CurrentDate) and hotelName = ‘Grosvenor’ (Guest Booking Hotel))  Guest.* (Guest ( fromDate <= CurrentDate and toDate >= CurrentDate Booking ) ( hotelName = ‘Grosvenor’ Hotel) )

e) List all guests currently staying at the Grosvenor Hotel Guest (guestNo, guestName, guestAddress) Hotel (hotelNo, hotelName) Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) What is the common attribute between Guest and Hotel?  Guest.* ( (fromDate <= CurrentDate and toDate >= CurrentDate) and hotelName = ‘Grosvenor’ (Guest Hotel Booking) ) hotelName = ‘Grosvenor’ (Guest (Hotel Booking)))

f) List the details of all rooms at the Grosvenor Hotel, including the name of the guest staying in the room if the room is occupied Room Guest  Room.*, guestName  (hotelName = ‘Grosvenor’ and fromDate <= CurrentDate and CurrentDate <= toDate) ((Room Hotel) (Booking Guest)) Not correct!  Room.*, guestName ( ( hotelName = ‘Grosvenor’ (Room Hotel) ) ( (fromDate <= CurrentDate and CurrentDate <= toDate) (Booking Guest)) ) A room without current booking will join a guest who booked the room before The room will be removed by the selection outside the outer join

Ctrl+G: 8. 5/10 Ctrl+I: Incorrect answer: -0 Ctrl+G: 8.5/10 Ctrl+I: Incorrect answer: -0.5 Ctrl+S: Incorrect style: -0.5 Ctrl+T: Missing table(s): -0.5 Ctrl+N: Missing name: -1 Ctrl+N: Incorrect file name: -1