DAD 220 Module Four Major Activity Template
Overview
Complete these steps as you work through the directions for this activity. Replace the bracketed text
with your screenshots and brief explanations of the work the screenshots capture. Size each screenshot
and its explanation to fit approximately one-quarter of the page with the description written below the
screenshot. Review the Template Screenshot Example linked in the guidelines and rubric for this
assignment to see how screenshots for your assignment should look.
Before you begin, follow steps one through four from the Module Three Major Activity Guidelines and
Rubric only to generate tables for this assignment. Then follow the steps below to complete the activity.
Organize and Analyze Data in Tables
1. Import the data from each file into tables.
A. Use the Quantigration RMA database, the three tables you created, and the three CSV
files preloaded into Codio.
B. Use the import utility of your database program to load the data from each file into the
table of the same name. You'll perform this step three times, once for each table.
i. Reference notes for this step: Import the CSV File into the MySQL table. Use the
following line terminators when importing: \r\n. Do not use IGNORE 1 LINES for
data that does not have column headers in the first row.
C. Provide the SQL commands you ran against MySQL to complete this step successfully.
LOAD DATA INFILE '/home/codio/workspace/customers.csv'
INTO TABLE Customers
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n';
LOAD DATA INFILE '/home/codio/workspace/rma.csv'
INTO TABLE RMA
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n';
LOAD DATA INFILE '/home/codio/workspace/orders.csv'
INTO TABLE Orders
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n';
IGNORE 1 ROWS;
2. Write basic queries against imported tables to organize and analyze targeted data. For each
query you run in this step, include a screenshot of the query and its output. Also, include a one-
to three-sentence explanation.
A. Write a SQL query that returns the count of orders for customers located only in
Framingham, Massachusetts.
i. This query will use a table join between the Customers and Orders tables. The
query will also use a WHERE clause.
ii. Record an answer to the following question: How many records were returned?
There are 505 records returned.
B. Write a SQL query to select all of the customers located in Massachusetts.
i. Use a WHERE clause to limit the number of records in the Customers table to
only those who are located in Massachusetts.
ii. Record an answer to the following question: How many records were returned?
982 records were returned.
C. Write a SQL query to insert four new records into the Orders and Customers tables using
the data below.
Customers Table
CustomerID FirstName Lastname StreetAddress City State ZipCode Telephone
100004 Luke Skywalker 17 Maiden Lane New York NY 10222 212-555-1234
100005 Winston Smith 128 Sycamore Street Greensboro NC 27401 919-555-6623
100006 MaryAnne Jenkins 2 Coconut Way Jupiter FL 33458 321-555-8907
CustomerID FirstName Lastname StreetAddress City State ZipCode Telephone
100007 Janet Williams 58 Redondo Beach Torrence CA 90501 310-555-5678
Blvd
INSERT INTO Customers (CustomerID, FirstName, LastName, Street, City, State, ZipCode, Telephone)
VALUES
(100004, 'Luke', 'Skywalker', '17 Maiden Lane', 'New York', 'NY', '10222', '212-555-1234'),
(100005, 'Winston', 'Smith', '128 Sycamore Street', 'Greensboro', 'NC', '27401', '919-555-6623'),
(100006, 'MaryAnne', 'Jenkins', '2 Coconut Way', 'Jupiter', 'FL', '33458', '321-555-8907'),
(100007, 'Janet', 'Williams', '58 Redondo Beach Blvd', 'Torrance', 'CA', '90501', '310-555-5678');
Orders Table
OrderID CustomerID SKU Description
1204305 100004 ADV-24-10C Advanced Switch 10GigE Copper 24 port
1204306 100005 ADV-48-10F Advanced Switch 10 GigE Copper/Fiber 44 port
copper 4 port fiber
1204307 100006 ENT-24-10F Enterprise Switch 10GigE SFP+ 24 Port
1204308 100007 ENT-48-10F Enterprise Switch 10GigE SFP+ 48 port
INSERT INTO Orders (OrderID, CustomerID, SKU, Description) VALUES
(1204305, 100004, 'ADV-24-10C', 'Advanced Switch 10GigE Copper 24 port'),
(1204306, 100005, 'ADV-48-10F', 'Advanced Switch 10 GigE Copper/Fiber 44 port copper 4 port fiber'),
(1204307, 100006, 'ENT-24-10F', 'Enterprise Switch 10GigE SFP+ 24 Port'),
(1204308, 100007, 'ENT-48-10F', 'Enterprise Switch 10GigE SFP+ 48 port');
D. In the Customers table, perform a query to count all records where the city is
Woonsocket and the state is Rhode Island.
i. How many records are in the Customers table where the field "city" equals
"Woonsocket"?
There are 7 records returned.
E. In the RMA database, update a customer's records.
i. Write a SQL statement to select the current fields of status and step for the
record in the RMA table with an OrderID value of "5175".
1. What are the current status and step?
The status, step for order 5175 is ‘pending’ and ‘Awaiting customer documentation’.
ii. Write a SQL statement to update the status and step for the OrderID, 5175 to
status = "Complete" and step = "Credit Customer Account".
1. What are the updated status and step values for this record? Provide a
screenshot of your work.
The update status and step are complete and credit customer account.
F. Delete RMA records.
i. Write a SQL statement to delete all records with a reason of "Rejected".
1. How many records were deleted? Provide a screenshot of your work.
596 records where deleted.
3. Create an output file of the required query results.
A. Write a SQL statement to list the contents of the Orders table and send the output to a
file that has a .csv extension.
SELECT * INTO OUTFILE '/home/codio/workspace/Lab4_Major_Activity.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
FROM Orders;