Question: SQL queries Suppose you have a database modeling a very simple car rental company, given by the following schema: Customer ( cID , cName, cCity,
SQL queries
Suppose you have a database modeling a very simple car rental company, given by the following schema:
Customer (cID, cName, cCity, cCCN, cLicense)
Car(carID, carMake, carModel, carModelNum, carColor, carYear)
CarType(carMake, carModel, carModelNum, carSize, carSeats)
Branch(bid, bCity, bStreet, bState, bPhone)
Rental(rID, cID, carID, pickupTD, pickupBid, returnTD, returnBid, cost)
In this schema, each customer is identified by a cID, and we also store the name, city, credit card number, and drivers license number of the customer. Each car has a make (e.g., Toyota), a model (e.g., Corolla), a model number (e.g., 400XL), and a year when it was manufactured. For each make and model, we also store the size of the car (e.g., compact, mid size, luxury) and the number of passengers it can hold. The car rental company has many branches, and for each car rental, we store which car was rented and by which customer, the total cost, and when and at what branch it was picked up and returned.
Write statements in SQL for the following queries
1. Output the cID of any passenger who has picked up a car in every state that has at least one branch
2. Output the cID and name of the passenger who spent the most money overall on rentals picked up during 2017
3. Output the cID and name of the customer(s) who made the most expensive rental picked up during 2017
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
