Question: Q12 in SQL 12. Write a stored function tot a l RaceTime that, given a racing number, the name of a race, and the date

12. Write a stored function tot a l RaceTime that, given a racing number, the name of a race, and the date of a race, returns the total race time for the car specified by the racing number in the given race. If the given race does not exist, the routine should throw an appropriate error. If the specified racing number did not take part in the existing race, the routine should throw an appropriate error. In the case that not all required lap times for the (existing) car in the (existing) race are available either until race finish or retirement, the routine should throw an appropriate error. If the (existing) race was not completed by the (participating) car in the race due to retirement but all lap times were available until retirement, the routine must not throw an error but return null. The total race time should be returned as an integer denoting milliseconds. Note that this stored routine has three arguments and you must declare them in the order given above. [12 marks] 1. Write one SQL statement to set up table MoSpo_HallOfFame according to the following Relational Schema: MoSpo_HallOfFame(hoFdriverId, hoFYear, hoFSeries, hoFImage, hoFWins, hoFBestRaceName, hoFBestRaceDate) primary key (hoFdriverId,hoFYear) foreign key (hoFdriverld) references MoSpo_Driver(driverld) foreign key (hoFBestRaceName,hoFBestRaceDate) references MoSpo_Race(raceName,raceDate)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
