0% found this document useful (0 votes)
49 views4 pages

Module 3 Lab Michael Marquardt

The document outlines a lab assignment where students connect to an employee database and perform various SQL operations, including renaming a table, inserting records, and executing joins between Employee and Department tables. Students are required to validate their work with screenshots and provide reflections on their processes. The assignment culminates in creating a CSV file containing specific employee records and detailing the data extraction process.
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)
49 views4 pages

Module 3 Lab Michael Marquardt

The document outlines a lab assignment where students connect to an employee database and perform various SQL operations, including renaming a table, inserting records, and executing joins between Employee and Department tables. Students are required to validate their work with screenshots and provide reflections on their processes. The assignment culminates in creating a CSV file containing specific employee records and detailing the data extraction process.
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
You are on page 1/ 4

DAD 220 Module Three Lab Template

Overview
To complete this lab, go to your Codio virtual lab environment and start a new terminal session. Once
there, connect to the employee information you entered in the Module Two lab. Then perform the
steps below to complete the activity. Manually enter any commands you are asked to write.

At the end of each step in the activity, replace bracketed text with a screenshot, brief explanation, or
both, as indicated. Size each screenshot and its explanation to fit about 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 an example of how screenshots for your assignment
should look.

Create Joins Between Tables

• Update the name of the Branches table that you created in the previous lab to say
"Department".

• Use an ALTER statement to RENAME the Branches table "Department".


• Capture these outputs in a screenshot to validate that you successfully completed this
step.

- I altered the name of the Branches to Department.

• Insert fields to the Department table so that joins can be performed on tables.

• INSERT INTO Department VALUES

(1, 'Accounting'),
(2, 'Human Resources'),
(3, 'Information Systems'),
(4, 'Marketing');

• Write a SELECT statement for this table to prove this step and validate that it ran
correctly with a screenshot.

- I inserted the correct Department_Name and their linking Department_ID.

• Perform joins between the Department and Employee tables and show results for how many
employees work in each of the four departments. This action will only provide information on
the records that are already there.

• Department 1 = Accounting

• Command: SELECT First_Name, Last_Name, Department.Department_Name


FROM Employee INNER JOIN Department ON Employee.Department_ID =
Department.Department_ID WHERE Employee.Department_ID = 1;
• Using SELECT statements similar to that above, perform joins to produce results for the
following tables:

• Department 2 = Human Resources


• Department 3 = Information Systems
• Department 4 = Marketing

• Capture the results of these joins and validate your work by providing a screenshot. You
should have the same number of records as you do employees.

- For all 4 departments I used the SELECT statement to get the first and last name as well as the
department name for each person that was in the tables in the Marquardt database and used an inner
join so it only selected matching rows from both left and right tables. For each of the departments I used
their unique Department_ID for each of the 4 departments.

• Populate the Employee table with information for 10 new employees.

• Give the employees unique names and include attributes for all necessary fields. Note:
Reference attributes from the lab in Module Two. Department ID values must be
between 1 and 4.

- I added 10 new records to the Employee table I gave them each a unique Employee ID for the
primary key. Also, I added their first and last name, their department ID, their classification, their status,
and their salary for each of the entries.

• Perform a join across the Employee and Department tables for each of the four departments.
New and existing records should be displayed in the results.

• Take a screenshot to capture the updated results that the Employee and Department
joins show and validate that they have run correctly. You should have the same number
of records as you do employees.

- This is the updated join statements on the employees and their department names after I added the
10 new records.

• Identify the resultant outputs of the commands you wrote and answer the following question:

• How many records are returned for employees in each department?

- For the Accounting department there are 5 records. For the Human Resources department there are
4 and for the Information Systems there are 4, as well a,s the last department, Marketing, there are 4
records.

• Create a CSV file that contains only the records of employees in Human Resources and
Information Systems. If you run this query multiple times, be sure to use a different file name
each time. MySQL will not overwrite an existing file.

- I created the CSV file that included both the Human Resourses department and the Information
Systems. I did have to go into the terminal and fix my spelling error so that CSV file would be correct.

• Enter the command listed below.

• Command: select First_Name, Last_Name, Department.Department_Name from


Employee inner join Department on Employee.Department_ID =
Department.Department_ID where Employee.Department_ID = 3 OR
Employee.Department_ID = 2 into outfile'/home/codio/workspace/HRandIS-
Employees.csv' FIELDS TERMINATED BY',' LINES TERMINATED BY '\r\n';

• Print the file output to the screen.

• In order to print your screen, start by refreshing your browser.


• Type the word "quit" after your MySQL prompt. Then press Enter to exit to the
Linux shell. Do not exit the virtual lab environment.
• Print the output of your file to the screen using these steps:
• Type "pwd" and press Enter. Then type "ls" and press Enter again to list
your files.
• Next, type "cat HRandIS-Employees.csv" and press Enter.
• Capture these outputs in a screenshot to validate that you successfully
completed this step.

• Reflection: Provide detailed insight on the prompts below. Explain your process and how and
why your process worked. Write your responses to the questions below in paragraph form.

• Process

• Explain how the joins you used in this assignment worked.

- The joins I used in this assignment were all inner joins. The inner joins only
select the matching rows from the left, Employee, and right, Department, tables.

• Describe why the commands you used were able to retrieve the Department
table when you selected the Department name.

- They work by selecting the first and last name as well as the department ID
from the employee table, the left table, and crossed referenced the department ID from
both tables to output the department name from the Department table, right table.

• File creation and extraction

• Identify how many records are in the file when you write the records of your
query to a CSV file.

- There are 8 records in the CSV file.

• Explain, in detail, the process of extracting data to a flat file.

- When creating the CSV file I had it select the first name, last name, and the
department name. I used an inner join to only select matching data from both of the
tables; employee and department. Then I added the ON statement to determine how
the two tables are related. Afterwards, I used the WHERE statement to only pick the
rows that had 2 or 3 in the Department ID in the Employee table. Then created the CSV
file to the codio workspace.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy