Question: The ONLY thing I need help with are these two questions: After the data are loaded, you will perform the analysis. First, find the average

The ONLY thing I need help with are these two questions:

  1. After the data are loaded, you will perform the analysis. First, find the average accident severity and the number of accidents for vehicles of type "motorcycle". Note the performance of your query. Your query may run so slowly that MySQL aborts running completing.
  2. Improve Query Performance
    • Look at the explain tool output and save the results to a graphic file.
    • From the explain results, how many rows have to be read per join?
    • Add an index named "accident_index" of type "index" on the accident_index
    • column in the accidents_2016 table and another index named "accident_index" of type "index" on the vehicles_2106 table.

But here is the rest of the assignment for context

C

  1. Create a MySQL schema named "accidents."
  2. Within the accidents schema, create a table named "accidents_2016" with the following columns:
    • accident_index as a varchar(13),
    • accident_severity as an int
  3. Within the accidents schema, create a table named "vehicles_2016" with the following columns:
    • accident_index as a varchar(13),
    • vehicle_type as a varchar(10)
  4. Within the accidents schema, create a table named "vehicle_type" with the following columns:
    • vcode int,
    • vtype as a varchar(100)
  5. Next, you will load the data for the three tables.
    • Load the accidents data. Note that "@dummy" is a placeholder for a column in the .csv file that you want to ignore during the load.
load data local infile '\\data\\Accidents_2016.csv' into table accidents_2016 fields terminated by ',' enclosed by '"' lines terminated by ' ' ignore 1 lines (@col1, @dummy, @dummy, @dummy, @dummy, @dummy, @col2 ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ) set accident_index=@col1,accident_severity=@col2;
  • Load the vehicle data.
load data local infile '\\data\\Vehicles_2016.csv' into table vehicles_2016 fields terminated by ',' enclosed by '"' lines terminated by ' ' ignore 1 lines (@col1, @dummy, @dummy, @col2 ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ) set accident_index=@col1,vehicle_type=@col2;
  • Load the vehicle type data.
load data local infile '...\\Data\\vehicletype.csv' into table vehicles_2016 fields terminated by ',' enclosed by '"' lines terminated by ' ' ignore 1 lines (@col1, @dummy, @dummy, @col2 ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ,@dummy, @dummy, @dummy, @dummy, @dummy ) set accident_index=@col1,vehicle_type=@col2; 

Thank you for any help

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!