Module 3 Lab Michael Marquardt
Module 3 Lab Michael Marquardt
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.
• Update the name of the Branches table that you created in the previous lab to say
"Department".
• Insert fields to the Department table so that joins can be performed on tables.
(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.
• 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
• 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.
• 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:
- 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.
• 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
- 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.
• Identify how many records are in the file when you write the records of your
query to a CSV 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.