0% found this document useful (0 votes)
3K views4 pages

DAD 220 Module 4 Major Activity Guide

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views4 pages

DAD 220 Module 4 Major Activity Guide

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • Overview
  • Organize and Analyze Data in Tables

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/[Link]'


INTO TABLE RMA
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'

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 were 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?

There are 982 records returned. I use the statement SELECT * FROM Customers WHERE State =
'Massachusetts';.

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

100007 Janet Williams 58 Redondo Beach Torrence CA 90501 310-555-5678


Blvd
I lost power again before I could screen shot.

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

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"?
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?

[Insert screenshot and brief explanation here.]

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.

[Insert screenshot and brief explanation here.]

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.

[Insert screenshot and brief explanation here.]

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.

[Insert screenshot and brief explanation here.]

Common questions

Powered by AI

To analyze customer distribution by states, such as Massachusetts, use a SQL query that counts entries grouped by the state field. An example query is SELECT COUNT(*) FROM Customers WHERE State = 'Massachusetts'. Ensuring proper indexing on the state column can optimize performance. This analysis helps in understanding geographical distribution, with the result showing 982 customers in Massachusetts .

Ensuring data integrity when inserting new customer and order records involves verifying that new data adheres to the defined schema constraints such as primary keys and foreign keys. For instance, when inserting into the Customers and Orders tables, ensure that unique CustomerID values are used and that corresponding OrderIDs correctly reference those customer entries. It is also vital to ensure that all required fields are filled, ensuring compatibility and integrity throughout the database .

Failing to capture screenshots during critical data operations in a database activity can lead to missed verification opportunities and reduced documentation integrity. Screenshots serve as evidence of operational steps, support troubleshooting, and provide a reference for future tasks or audits. Missing them could lead to difficulties in tracking changes or errors, impacting collaborative work and accountability .

Exporting data from a database table to a CSV file involves writing a SQL SELECT statement that outputs the desired table data and redirects the output into a file with a .csv extension using INTO OUTFILE directive. For example, SELECT * FROM Orders INTO OUTFILE 'orders.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'. This is significant for data sharing, reporting, and backup purposes where tabular data is needed in a universally accessible format .

To update specific records in a database using SQL, first write a SELECT statement to view the current fields of interest for the records you intend to update. After verifying this, use an UPDATE statement specifying the table, conditions for selection, and new values for the fields. Finally, perform another SELECT query to confirm the changes. For instance, change and then verify the status and step values by selecting the updated records .

Proper documentation, including code comments and screenshots, plays a crucial role in enhancing comprehension and reproducibility of database activities. It provides clarity on the procedural logic and intent behind specific queries and operations, facilitates error troubleshooting, and aids in knowledge transfer to other team members or stakeholders. Lack of it could result in misunderstandings or errors in future database management efforts .

Managing large datasets when writing SQL statements involves challenges such as handling of bulk data entry efficiently, ensuring database speed, and maintaining referential integrity. Using batch processing techniques like INSERT INTO with multiple rows or utilizing stored procedures can optimize performance. Ensuring indexing and database normalization can address slow queries and storage issues, respectively .

To perform data importation from CSV files into MySQL tables effectively, you should use the LOAD DATA INFILE command, specifying the fields and lines terminators according to your data format. For instance, fields may be terminated by a comma and lines by "\r\n". It is also important to assess whether the CSV file includes column headers to decide if you should skip the first line. Careful consideration of data format compatibility ensures a smooth data import process into the database .

Deleting database records with a specific criterion, such as a "Rejected" reason, involves using a DELETE SQL statement with a WHERE clause that matches the records to be removed. For instance, DELETE FROM RMA WHERE Reason = 'Rejected'. The purpose of this operation is to remove irrelevant or obsolete data, which aids in maintaining a clean and efficient database. However, implications include potential data loss if accidentally executed without backups or verification and possible referential integrity violations if foreign key constraints are not properly managed .

To extract data for customers located in Framingham, Massachusetts, a SQL query involving a table join between Customers and Orders and a WHERE clause filtering based on the customer's location is required: SELECT COUNT(*) FROM Customers JOIN Orders ON Customers.CustomerID = Orders.CustomerID WHERE City = 'Framingham' AND State = 'Massachusetts'. The interpretation of this query showed 505 records, indicating active customer-order transactions within that locality .

You might also like