Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Update the name of the Branches table that you created in the previous lab to say Department. Use an ALTER statement to successfully RENAME the

Update the name of the Branches table that you created in the previous lab to say "Department".
Use an ALTER statement to successfully RENAME the "Branches" table to "Department".
Capture these outputs in a screenshot to validate that youve successfully completed this step.
Insert fields to the Department table so that youll be able to perform joins on them.
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.
Now, perform joins between the Department and Employee tables and show results for how many employees work in each one of the four departments. This 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 the one 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.
Populate the Employee table with information for ten new employees.
Give them unique names and include attributes for all necessary fields. (Note: Please reference attributes from the lab in Module Two. Department ID values must be between 1 and 4.)
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 to validate that they have run correctly. You should have the same number of records as you do employees.
Identify the resultant outputs of the commands that youve written:
How many records are returned for employees in each department?
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.
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
';
Print the file output to the screen.
In order to print your screen, start by refreshing your browser.
Youll need to type the word quit after your MySQL prompt and then press Enter to exit to the Linux shell. Do not exit the virtual lab environment itself.
Next, print the output of your file to the screen by following these steps:
Type pwd and press Enter, then type ls and press Enter again. This will list your files.
Now, type cat HRandIS-Employees.csv and press Enter.
Capture these outputs in a screenshot to validate that youve successfully completed this step.
Reflection: Provide detailed insight on the prompts below by explaining your process along with how and why it ultimately worked.
Process
Explain how the joins you used in this assignment worked.
Describe why the commands you used were able to retrieve the Department table when you selected the Department name.
File creation and extraction
Identify how many records are in the file when you write the records of your query to a CSV file.
Explain, in detail, the process of extracting data to a flat file.
stuck on this part mysql> SELECT Employee.First_Name, Employee.Last_Name, Department.Department_Name FROM Employee INNER JOIN Department ON Employee.Department_ID = Department.Department_ID WHERE Employee.Department_ID =2);
ERROR 1064(42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
mysql> SELECT Employee.First_Name, Employee.Last_Name, Department.Department_Name
->
-> FROM Employee
->
-> INNER JOIN Department ON Employee.Department_ID = Department.Department_ID
->
-> WHERE Employee.Department_ID =2
->);
ERROR 1064(42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 8
mysql> INSERT INTO Employee VALUES
->(1, 'Jane', 'Doe', 1);
ERROR 1136(21S01): Column count doesn't match value count at row 1
mysql> INSERT INTO Employee VALUES (1, 'Jane', 'Doe', 3);
ERROR 1136(21S01): Column count doesn't match value count at row 1
mysql> INSERT INTO Employee VALUES (3, 'Jane', 'Doe', 3);
ERROR 1136(21S01): Column count doesn't match value coun

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

ISBN: 3030302776, 978-3030302771

More Books

Students also viewed these Databases questions

Question

Discuss the role of each tier in three-tier architecture.

Answered: 1 week ago

Question

Write a letter asking them to refund your $1,500 down payment.

Answered: 1 week ago