Question: 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

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 (hoFdriverId) references MoSpo_Driver(driverId) foreign key (hoFBestRaceName,hoFBestRaceDate) references MoSpo_Race(raceName,raceDate) Your code must execute without error, assuming that all other tables have been set up by running script a2 -setup. sq 1 . [12 marks] The data types you choose for the columns should be most appropriate for the data they will contain. You must also accommodate the following requirements: (a) For table and column names you must pick exactly the names used in the schema above (otherwise you will lose marks as tests will fail). (b) hoFYear is a 4-digit number representing a year between 1901 and 2155 (or 0000). (c) hoFSeries is one of the following strings: BritishGT, Formulal, FormulaE, SuperGT. Please make sure you use the correct spelling. These column values, when ordered, should always appear in the order they have been listed above. Values for this attribute must not be missing. (d) hoFWins is a positive integer number and never larger than 99. The default is 0 but values can be missing. (e) hoFlmage is a path to an image document which is a string never longer than 200 characters. This value can be missing. (f) Equip any foreign key constraints with constraint names of your choosing. (g) Ensure that if a driver is deleted from the database their corresponding hall of fame entries are deleted automatically too. (h) Ensure that if a race is deleted from the database then foreign key values in hall of fame entries that reference it are automatically set to null. 6. List all racing drivers (driver id, name and dob) whose last name begins with the same letter as their first name. The name of the driver should be given as a string consisting of the initial from the first name, followed by a blank, followed by their last name. So a driver with first name Alan and last name Turing would be listed as A Turing. The headings must look like this: [6 marks] driverId drivername driverDOB 7. List for each racing team how many drivers they have associated with them. Only include teams with more than one driver. The headings must look like this: [6 marks] CeamName numberofDriver 8. For each race list the fastest lap time. The information provided should include race name, race date, lap time. No races must appear for which there is no proper such minimal time available. The headings must look like this: [6 marks] 9. Given a race (name) and a year, 'total pitstops" is the total number of pitstops of all cars in the given race that year. For each race name compute the average of the number of 'total pitstops" based on the years we have data for. The headings must look like this: [6 marks] raceName avgstops 10. A car (of a race entry) retires in a lap if the corresponding attribute lapinfocompleted has value 0. Find out all the (different) makes of cars that had to retire in a race in the year 2018 . The heading must look like this: [6 marks] carMake 11. For each race, compute the highest number of pitstops any car had. Provide race name and date as well as the highest number of stops. Races with no pitstops recorded at all should appear with a 0 . The headings must look like this: [6 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
