Its 410 port  Option #1: Your Portfolio Project consists of two items, a lessons learned reflection report and a database design and analysis project. Lessons Learned and Reflection Write a 2- to 3-page summary that outlines the lessons you learned in this database class. Reflect on how these lessons can be applied toward more effective database management and reporting

Its 410 port
 Option #1:
Your Portfolio Project consists of two items, a lessons learned reflection report and a database design and analysis project.
Lessons Learned and Reflection
Write a 2- to 3-page summary that outlines the lessons you learned in this database class. Reflect on how these lessons can be applied toward more effective database management and reporting.
Database Design and Analysis
Use the Accidents_2016.csv file below to implement the following steps for your database project.

  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 ‘\n’
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 ‘\n’
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\\vehicle_type.csv’
into table  vehicle_type
fields  terminated by ‘,’
enclosed by  ‘”‘
lines  terminated by ‘\n’
ignore 1  lines

  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 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.

alter table accidents_2016
add index accident_index (accident_index asc);
alter table vehicles_2016
add index accident_index (accident_index asc);
After adding the indices, rerun the query explanation tool and determine the number of rows to be read per join.

  1. Find the median accident severity.

MySQL does not have a median function so to find the median accident severity, you will have to write a Python script.

  • You’ll need to install Python and the PyMySQL module.
  • Install Python version 2.7 or 3.4 from www.python.org.

To install the PyMySQL module, run the following command in a Windows command prompt after Python has been installed:
python -m pip install  –index-url=https://pypi.python.org/simple/ –trusted-host pypi.python.org PyMySQL

  1. b) Create an accident median table

create  table accident_medians
(
vtype varchar(100),
severity int
);

  • Run the following Python script:

import pymysql
myConnection  = pymysql.connect(host=’localhost’, user=’****’, passwd=’****’, db=’accidents’)
cur = myConnection.cursor()
cur.execute(‘SELECT vtype FROM vehicle_type WHERE  vtype LIKE “%otorcycle%”;’)
cycleList = cur.fetchall()
selectSQL = (”’
SELECT  t.vtype, a.accident_severity
FROM accidents_2016 AS a
JOIN vehicles_2016 AS v ON  a.accident_index = v.Accident_Index
JOIN vehicle_type AS t ON  v.Vehicle_Type = t.vcode
WHERE t.vtype LIKE %s
ORDER BY  a.accident_severity;”’)
insertSQL = (”’INSERT INTO accident_medians  VALUES (%s, %s);”’)
 
for cycle  in cycleList:
cur.execute(selectSQL,cycle[0])
accidents = cur.fetchall()
quotient, remainder =  divmod(len(accidents),2)
if  remainder:
med_sev =  accidents[quotient][1]
else:
med_sev =  (accidents[quotient][1] + accidents[quotient+2][1])/2
print(‘Finding median  for’,cycle[0])
cur.execute(insertSQL,(cycle[0],med_sev))
myConnection.commit()
myConnection.close()
Write each query you used in Steps 1 – 8 in a text file. If a query produced a result set, the list then first ten rows of each row set after the query. Bundle your lessons learned report, your queries and your query results text file, and your MySQL query explanations from both before and after adding table indexes into a single zip file and submit that zip file as your final portfolio.
Option #2:
Your Portfolio Project consists of two items, a lessons learned reflection report and a database design and analysis project.
Lessons Learned and Reflection
Write a 2- to 3-page summary that outlines the lessons you learned in this database class. Reflect on how these lessons can be applied toward more effective database management and reporting.
Database Design and Analysis 
The following database project will create an educational attainment “demand” forecast for the state of California for years greater than 2010. The demand forecast is the expected number of population who have obtained a certain level of education. The population is divided into age groups and education attainment is divided into different levels. The population of each group is estimated for each year up to year 2050. Implement the following steps to obtain and educational demand forecast for the state of California. The files can be downloaded below.

  1. Create a ca_pop schema in your MySQL database.
  2. Using your ca_pop schema, create an educational_attainmenttable which columns match the columns in the Excel spreadsheetcsv.
  3. Using your ca_pop schema, create a pop_proj table which columns match the columns in the Excel spreadsheet csv.
  4. Using the data loading technique for a csv file you learned in Module 1, load the data in csv into the table educational_attainment.
  5. Using the data loading technique for a csv file you learned in Module 1, load the data in csvinto the table pop_proj.
  6. Write a query to select the total population in each age group.
  7. Use the query from Step 6 as a subquery to find each type of education attained by the population in that age group and the fraction of the population of that age group that has that educational attainment. Label the fraction column output as For instance, the fraction of the population in age group 00 – 17 who has an education attainment of Bachelor’s degree or higher is 0.0015, which is the coefficient.
  8. Create a demographics table from the SQL query from Step 7.
  9. Create a query on the pop_proj table which shows the population count by date_year and age.
  10. Use that query from Step 9 as a subquery and join it to the demographics table using the following case statement:

demographics.age =
case
when  temp_pop.age < 18 then ’00 to 17′
when  temp_pop.age > 64 then ’65 to 80+’
else  ’18 to 64′
end
“temp_pop” is an alias for the subquery. Use the following calculation for the demand output:
round(sum(temp_pop.total_pop * demographics.coefficient)) as demand
Output the demand grouped by year and education level.
Write each query you used in Steps 1 – 10 in a text file. If a query produced a result set, the list then first ten rows of each row set after the query. Bundle your lessons learned report and your query results text file into a single zip file and submit that zip file as your final portfolio.
 

GET HELP WITH YOUR HOMEWORK PAPERS @ 25% OFF

For faster services, inquiry about  new assignments submission or  follow ups on your assignments please text us/call us on +1 (251) 265-5102

Write My Paper Button

WeCreativez WhatsApp Support
We are here to answer your questions. Ask us anything!
👋 Hi, how can I help?
Scroll to Top