DAD 220 Database Documentation Dylan Roscioli

docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

220

Subject

Mechanical Engineering

Date

Dec 6, 2023

Type

docx

Pages

9

Uploaded by MagistrateExplorationStarling39

Report
DAD 220 Database Documentation Template Complete these steps as you work through the directions for Project One. Replace the bracketed text with your screenshots and brief explanations of the work they capture. Each screenshot and its explanation should be sized to approximately one quarter of the page, with the description written below the screenshot. Follow these rules for each of the prompts and questions below. Review the example document located in the Project One Supporting Materials for assistance. Step One: Create a Database 1. Navigate to your online integrated development environment (IDE). List and record the SQL commands that you used to complete this step here: After going to the codio learning environment I used the command mysql; to enter in the IDE. 2. Create a database schema called QuantigrationUpdates. List out the database name. Provide the SQL commands you ran against MySQL to successfully complete this in your answer:
Using the CREATE DATABASE clause I established our new database ‘QuantigrationUpdates’. From here I used the show databases with a like parameter to only show the databases that started with Q and ended with s, just to make the results more succinct. 3. Using the entity relationship diagram (ERD) as a reference, create the following tables with the appropriate attributes and keys: a. A table named Customers in the QuantigrationUpdates database, as defined on the project ERD. Provide the SQL commands you ran against MySQL to complete this successfully in your answer: After referencing the ERD I was able to get all of the information I needed for creating the columns of information in my Customers table and how their values would be represented. I was also given the primary key here. Using a create table clause I made the Customers table and inputted the columns I wanted from the ERD. b. A table named Orders in the QuantigrationUpdates database, as defined on the project ERD. Provide the SQL commands you ran against MySQL to complete this successfully in your answer:
Again referencing the ERD I was able to pull the information and what the primary and foreign keys were going to be. Using the create table clause I created the Orders table but also added a foreign key in this table, so it had the ability to reference the Customers table. c. A table named RMA in the QuantigrationUpdates database, as defined on the project ERD. Provide the SQL commands you ran against MySQL to complete this successfully in your answer: Using the ERD again, inputted the columns, primary and foreign keys so this table could reference the Orders table. Step Two: Load and Query the Data 1. Import the data from each file into tables. Use the QuantigrationUpdates database, the three tables you created, and the three CSV files preloaded into Codio.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Use the import utility of your database program to load the data from each file into the table of the same name. You will perform this step three times, once for each table. Using the LOAD DATA INFILE I was able to load the csv’s into the tables I just established using the FIELDS and LINES TERMINATED BY clauses so that there would not be multiple values in the same column. 4. Write basic queries against imported tables to organize and analyze targeted data. For each query, replace the bracketed text with a screenshot of the query and its output. You should also include a 1- to 3-sentence description of the output. Write an SQL query that returns the count of orders for customers located only in the city of Framingham, Massachusetts. i. How many records were returned?
Using a SELECT Count I was able to count the Orders table primary key while joining with the Customers table using the foreign key we set up so it could also see where those orders had been made by customers who’s city and state matched Framingham and Massachusetts which returned to me a total of 505. Write an SQL query to select all of the Customers located in the state of 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? Again, I chose to use the SELECT COUNT here because it would return to me a total number of records rather than a SELECT* which would return to me all of the records, but I would have to count them. From there I just put the WHERE statement to only count where the customers state was equal to Massachusetts. Write a SQL query to insert four new records into the Orders and Customers tables using the following data: Customers Table CustomerID FirstName LastName StreetAddress City State ZipCode Telephone 100004 Luke Skywalker 15 Maiden Lane New York NY 10222 212-555-1234 100005 Winston Smith 123 Sycamore Street Greensbor o NC 27401 919-555-6623 100006 MaryAnne Jenkins 1 Coconut Way Jupiter FL 33458 321-555-8907 100007 Janet Williams 55 Redondo Beach Blvd Torrence CA 90501 310-555-5678
Using INSERT INTO we were able to enter the values given to us into our already established table. 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 Again we continued using INSERT INTO considering we were just inputting values into the already established table we set up using the ERD. In the Customers table, perform a query to count all records where the city is Woonsocket, Rhode Island. i. How many records are in the Customers table where the field “city” equals “Woonsocket”?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Using SELECT COUNT I counted the primary key (I could’ve also just used * to be returned the same value) from customers where the city was equal to Woonsocket which gave me a total of 7. In the RMA database, update a customer’s records. i. Write an 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? Again, using SELECT but this time only wanting info on the Status and Step we used WHERE to return to us those values only where the order ID was 5175 which gave us Status = Pending and Step = Awaiting customer Documentation. ii. Write an 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?
After updating the RMA table to set the status to Complete and Step to Credit Customer account, we used a select statement searching for those two columns on that order to show us the newly updated values of Status = ‘Complete’ and Step = ‘Credit Customer Account’. Delete RMA records. i. Write an SQL statement to delete all records with a reason of “Rejected.” 1. How many records were deleted? To delete the files associated with that value we used a DELETE FROM statement with the WHERE parameter to have it look for only where the reason = Rejected. We deleted 596 rows. 5. Update your existing tables from “Customer” to “Collaborator” using SQL based on this change in requirements. Provide the SQL commands you ran against MySQL to complete this successfully in your answer: a. Rename all instances of “Customer” to “Collaborator.”
Here I used CREATE VIEW to create a way to look at the same information that was already inputted into the Customers table but replacing the instances of Customer with Collaborator. This way they could still have their normal table that they have been using, but this VIEW will be available to show the public. Also, if they did want to change the original table then ALTER TABLE with RENAME statements could be used to go in and just change the CustomerID column to CollaboratorID and then RENAME the Table to Collaborators. 6. Create an output file of the required query results. Write an SQL statement to list the contents of the Orders table and send the output to a file that has a .csv extension. Using the SELECT * because we wanted every column from the Orders table I used the INTO OUTFILE command to describe a location for that CSV and then used the FIELDS TERMINATED BY, ENLOSED BY, and LINES TERMINATED BY statements to make this be comma-separated values that showed the values separated by ‘,’ enclosed in ‘”’ and each row ended by going to the next row down.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help