Ch6 HW Solution1
Ch6 HW Solution1
a. For each flight, list the flight number, the departure airport for the first
leg of the flight, and the arrival airport for the last leg of the flight. DEPARTURE = Flight_numberMIN Leg_number (FLIGHT_LEG) Departure_airport = Flight_number,Departure_airport_code (DEPARTURE * FLIGHT_LEG ) ARRIVAL = Flight_numberMAX Leg_number (FLIGHT_LEG) Arrival _airport = Flight_number, Arrival_airport_code (ARRIVAL * FLIGHT_LEG ) RESUL<- Departure_airport * Arrival _airport DEPARTURE = Flight_numberMIN Leg_number (FLIGHT_LEG) ARRIVAL = Flight_numberMAX Leg_number (FLIGHT_LEG)
RESUL<-Flight_number,Departure_airport_code,Arrival_airport_code((DEPARTUREARRIVAL)*AIRPORT)
b. List the flight numbers and weekdays of all flights or flight legs that
depart from Houston Intercontinental Airport (airport code 'IAH') and arrive in Los Angeles International Airport (airport code 'LAX'). DEP_HOUS <- Departure_airport_code = 'IAH'(FLIGHT_LEG) ARR_LA <- Arrival_airport_code = 'LAX'(FLIGHT_LEG) HOUSTOLA <- DEP_HOUS * ARR_LA
HOUSTOLA <- DEP_HOUS * ARR_LA RESULT <- Flight_number, Departure_airport_code, Scheduled_departure_time, Arrival_airport_code,
Scheduled_arrival_time, Weekdays
(HOUSTOLA* FLIGHT)
a. How many copies of the book titled The Lost Tribe are owned by the
library branch whose name is 'Sharpstown'?
TLT <- Title = 'The Lost Tribe'(BOOK) SHARP <- Branch_name='Sharpstown'(LIBRARY_BRANCH) RESULT <- No-of-copies ( ( TLTSHARP )* ( BOOK_COPIES ) )
b. How many copies of the book titled The Lost Tribe are owned by each
the library branch? TLT <- Title = 'The Lost Tribe'(BOOK)
RESULT <-
c. Retrieve the name of all borrowers who do not have any books checked
out. NULL_LOAN <- Date_out = 'null'(BOOK_LOANS) RESULT <- Name (NULL_LOAN * BORROWER)
d. For each book that is loaned out from the 'Sharpstown' branch and
whose Due_date is today, retrieve the book title, the borrower's name, and the borrower's address. SHARPS <- Branch_name = 'Sharpstown'(LIBRARY_BRANCH) DUE_TODAY <- Due_date=TODAY(BOOK_LOANS) DUE_BOOK <- ( SHARPS BOOK ) * DUE_TODAY RESULT <- Title, Name, Address (DUE_BOOK * BORROWER)
e. For each library branch, retrieve the branch name and the total number
of books loaned out from that branch.
CNT_LOAN(branched, cnt) <- Branch_id COUNT Book_id(BOOK_LOANS) RESULT <- Branch_name, cnt (CNT_LOAN*LIBRARY_BRANCH)
f. Retrieve the names, addresses, and number of books checked out for all
borrowers who have more than five books checked out. CNT_LOAN(Cno, cnt) <- Card_no COUNT Book_id (BOOK_LOANS) MORE <- cnt>5(CNT_LOAN) RESULT <- Name, Address, cnt ( BORROWER MORE)
g. For each book authored (or coauthored) by Stephen King, retrieve the
title and the number of copies owned by the library branch whose name is Central. CENTRAL <- Branch_name='Central'(LIBRARY_BRANCH) AUTH <- Author_name='stephen king' (BOOK_AUTHORS) STEPHEN_BOOK <- AUTH * BOOK
RESULT <- Title, No_of_copies ((BOOK_COPIES * CENTRAL) * STEPHEN_BOOK)