Module 3 Case Study 2-Worksheet
Module 3 Case Study 2-Worksheet
Team members:
Member1
Member2
Member3
Member4
Query 1:
Question: Return the vin numbers of all vehicles with make “Toyota”.
Explanation: This query should return a table with only one column containing vin number(s).
Query 2:
Question: Return the vin number and ride height of the 4WD which has the highest ride height with
“alloy” wheels.
Explanation This query should return a table with two columns. The first column should contain the
vin number and the second column should contain the ride height
Question Return the user(s) who has been on the most trips with driver “Verity Choi”.
Explanation This query should only return a table contain a single column of userID(s).
Query5:
Question: Return a combined list of the average ratings for both vehicles and drivers.
Explanation
This query should return a table with three columns: rating type, rating identifier and
average rating value. The rating type should either be “Vehicle” or “Driver”. The rating
identifier will then be either the vehicle vin number or driverID depending on the rating
type. Note: The output screenshot for this question only needs to show 10 tuples.
Question: The police suspect one of our drivers may have been involved in a robbery on the
3/3/2020. They have requested the names of all drivers who were working that night anytime
from 8PM to 10PM.
Explanation: This query should return the drivers first name and last name. The time conditions
for this question are inclusive, i.e. including 8PM and 10PM. A driver is classified as “working”
between the start and end time (inclusive) of a trip which they drive for. Your solution must use
at least one non-correlated nested query.
Query7:
Question: Our Board of Directors want to perform a feasibility audit on our client emergency
contact system. We need a list of all the trip instances where an emergency contact of the
passenger was also on a trip at the same time.
Explanation: This query should return the full tuple for each instance in the Trip table which
meets the requirements. You may assume that assume the first name and last name in the
EmergencyContact table is equivalent to the first name and last name in the User table. If an
emergency contact has the same name as someone listed in the user table, they are referring to
the same person. A trip’s start and end times are inclusive of the time a user is defined as being
on a trip. Your solution must use at least one correlated nested query.
Explanation: Your SQL solution should create a view which shows the vehicle vin number and
the amount time that vehicles has been used in ride sharing activities. The time should be
recorded in the format, “hours:minutes:seconds”. You may need to create a secondary helper
view in order to answer this question. The view(s) can be named as you please. If you use
several views, you should only include an Output Screenshot for the final view. Note: The
output screenshot for this question only needs to show 10 tuples.
Hint: You may want to use the TIMESTAMPDIFF and SEC_TO_TIME MySQL functions