Question: Consider a database with three relation instance shown below. The schema describes the database containing information about the cars. The drivers relation includes information about

Consider a database with three relation instance shown below. The schema describes the database containing information about the cars. The drivers relation includes information about the id, name, rating and age of the driver. The reserves relation provides information about charges being charged by the drivers for reserving cars. The cars relation provides the information about its id, name and color. Domain of each field is listed after the field name.

drivers(did:integer, dname:string, rating:integer, age:integer)

reserves(did:integer, cid:integer, charges:integer)

cars(cid:integer, cname:string, color:string)

Give the SQL queries for the following based on the given schema.

a) Find the names of all drivers who reserved a red and a green car.

b) Find the names of all drivers who reserved a non-blue car.

c) Find the average age of drivers for each rating.

d) Find the names of the drivers who drives the Skoda cars.

e) Find the names of the cars which was not reserved by any driver.

f) Find the ids of the drivers who reserved the cars for charges more than the charges of any other car.

g) Find the names of the cars which was reserved by the drivers who have same rating.

h) Find the age of youngest drivers with rating less than 5.

i) Find the names of drivers who reserves the same car that Boris reserved.

j) Retrieve pairs of dids such that drivers with first did charges more than driver with second did for the same car.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!