Please help me explain #1 - 4 of the word document part. Thank you
Goal of this assignment: Practice simple SQL statements by creating, loading, exporting and importing the EMPLOYEE table in the COMPANY database and explain how outer join works. At the end of this assignment you should know how foreign key (or referential) constraints. There is no screenshot you need to capture for this assignment; however, you will need to turn in a word document that answers four things listed in the 'What to turn in' section at the end of this document. Requirements: MySQL is successfully installed and running. For this assignment, you can use either the CLI or Workbench. However, the steps described in this assignment are only for the CLI, not the Workbench even though the SQL commands are pretty much the same. Refer to Task 1 in WA2 for how to invoke the mysql CLI. Before you start, make sure you can connect to the database and in the case of the CLI, you should see the 'mysqly' prompt. Note: In this document, text after //, represents comments, not part of the SQL command. Task 1: Create Database COMPANY Use 'create database
;' to create database COMPANY. For example, mysql>create database COMPANY; To verify it was created successfully, mysql>show databases; Task 2: Create the EMPLOYEE table Here is schema with referential integrity constraint displayed for relation(or table) EMPLOYEE. Fname Minit Lname SsnBdateAddress SexSalary Super_ssn Dno Create a text file named 'employee.sql' that contains the following lines CREATE TABLE if not exists EMPLOYEE Fname varchar(15) not null, Minit varchar(1), Lname varchar(15) not null, Ssn char(9), Bdate date, Address varchar(50), Sex char, Salary decimal(10,2), Super ssn char(9), Dno integer(4), primary key (Ssn), foreign key (Super_ssn) references employee(Ssn) engine-innodb; Before you create the table, you need to select COMPANY as the default database if you haven't done so. Also, the following command assumes employee.sql is located in your current directory (i.e. the directory from where you invoked the CLI.) If not, you will need to provide the full pathname of your employee.sql file mysql> select database);// If it doesn't return COMPANY, enter 'use COMPANY' and hit return, and run 'select database():' again to make sure COMPANY is the database you are in mysql>source employee.sql mysql>describe EMPLOYEE; I/ This command should return something like the following, Field Type | Null | Key Default | Extra | Fname varchar(15 NOI NULL I Minit varchar1) YESNULL I Lname varchar(1 NO I NULL I I Ssn Bdate I date | Address Ivarchar(50) | YES I NULL I char(9) NO PRI I YES NULLI char1) YES NULLI ex Salary decimal (10,2) YESNULL I Super_ssn | char(9) YES MUL I NULL I I I Dno int(4) | YES NULL| 10 rows in set (0.01 sec) Task 3: Load the EMPLOYEE Table Open the employee.xlsx (uploaded with this assignment) and save it as a Text (Tab delimited) file, and name it employee.txt. Copy the employee.txt to a directory accessible by MySQL, for example, C:Temp. Make sure COMPANY is still your default database mysql > load data infile ' into table EMPLOYEE; // For example, mysql load data infile /Temp/employee.txt' into table EMPLOYEE; mysql selectfrom EMPLOYEE;//You should see 40 rows returned from EMPLOYEE table Task 4: Update, backup and restore EMPLOYEE Table // Update EMPLOYEE by adding employee 'Leonard Bernstein'. mysql>insert into EMPLOYEE(Fname, Lname, Ssn) values (Leonard', "Bernstein', '555667777'); mysql select count(* from EMPLOYEE; // It should return 41 rows // Backup EMPLOYEE Table to a file named 'employee.bkup'.I use 'C:/Temp' as an example mysql>select*into outfile '/Temp/employee.bkup' from EMPLOYEE; // It should create a file named 'employee.bkup' under C:/Temp in this example mysql>truncate table EMPLOYEE; / Remove all rows from EMPLOYEE table to simulate the corruption of EMPLOYEE table // Now restore EMPLOYEE table with the backup you just made mysql>load data infile 'Temp/employee.bkup' into table EMPLOYEE // You should get an error because of the foreign key constraint violation, which is expected What to turn in Submit a word document that (10 %) Explain why this situation happened. Employee table was initially loaded with 40 rows without any errors. You successfully added one employee. The table was backed up to a file without errors but you can't reload the table with the backup you made (20 %) Explain how you would fix the problem without turning off foreign-key-checks (see more below). Document the steps (including all SQL commands used) to restore the table to its contents before the crash (simulated by truncating the table). Your table is fully restored if it contains 41 employees data correctly (10 %) Explain the possible issue that might be caused by turning off foreign_key_checks. Foreign_key_checks is a variable in MySQL. It is 'on' by default. You can turn it off by 'set foreign_key_checks 0;' but it may or may not cause some issues (10% each/60 % total) Create two tables to demonstrate how left (outer) join and right (outer) join works. Also demonstrate how to simulate the full (outer) join using 'UNION' and 'UNION ALL. Explain the difference between 'UNION' and UNION ALL. Copy and paste your screen output (both the SQL command and results) to your word document Your answers should include the following components 1, 2, 3, 4. Show the contents(or state) in both tables, say TABLE A and TABLE B. A 'select * from ...' will be suffice a. b. Show the results from table A left join tableB c. Show the results from table A right join table B d. Show the results from UNION b) and c) e. Show the results from UNION ALL b) and c) f. Explain the difference between d) and e) Note: Please keep the two tables simple, just enough to illustrate your point. M 55000 N M 40000 8886655555 F 43000 8886655554 M 30000 333445555 5 F 25000 9876543214 M 38000 333445555 5 F 25000 3334455555 M 25000 9876543214 M 85000 N M 89000 N M 81000 N James E B org on Wallace 888665555 2027-11-10 450 Stone, Houston, TX 3334455551945-12-08 638 Voss, Houston, TX 987654321 123456789 999887777 JenniferS 1931-06-20 291 Berry, Bellaire, TX 1955-01-09 731 Fondren, Houston, TX 1958-07-19 3321 Castle, Spring, TX 1952-09-15 971 Fire Oak, Humble, TX 1962-07-31 5631 Rice, Houston, TX 1959-03-29 980 Dallas, Houston, TX 1966-10-10 123 Peachtree, Atlanta, GA 1950-10-09 4333 Pillsbury, Milwaukee, WI 1975-06-30 7676 Bloomington, Sacramento, CA RameshK Narayan666884444 oyce Ahmad V Jabbar 453453453 987987987 D James 6 C James 555555500 C Jones 1966-01-12 2342 May, Atlanta, GA 15 1958-01-16 134 Pelham, Milwaukee, WI 222222200 222222201 1954-05-22 266 McGrady, Milwaukee, WI 222222202 1944-06-211967 Jordan, Milwaukee, WI 2222222031966-12-16 112 Third St, Milwaukee, WI 222222204 222222205 1960-03-21 565 Jordan, Milwaukee, WI 333333300 1970-10-23 6677 Mills Ave, Sacramento, CA 333333301 1970-01-07 145 Bradbury, Sacramento, CA M 92000 N M 56000 222222200 7 M 53000 222222200 7 M 62500222222200 7 F 61000 2222222017 F 43000 2222222017 OS 1967-11-11 263 Mayberry, Milwaukee, WI M 44000 333333300 6 F 70000 444444400 7 M 60000 444444400 7 M 48000 444444400 7 M 62000 555555500 6 M 96000 N F 36000 666666600 8 F 44000 666666600 8 M 41000 666666601 8 F 38000 666666603 8 M 41500 666666603 8 M 44500 666666604 8 M 29000 666666602 8 M 33000 666666602 8 F 32000 666666602 8 M 34000 666666607 8 M 32000 666666610 8 M 37000 6666666118 M 33500 666666612 8 1956-06-19 111 Hollow, Milwaukee, WI 1966-06-18 233 Solid, Milwaukee, WI 1977-07-31 987 Windy St, Milwaukee, WI 444444402 S Snedden444444403 555555501 1969-04-16 222 Howard, Sacramento, CA 666666600 1968-04-17 8794 Garfield, Chicago, IL 666666601 666666602 666666603 66666660419 666666605 666666606 1949-08-16 213 Delk Road, Seattle, WA 666666607 1962-05-15 122 Ball Street, Dallas, TX 666666608 1967-05-19 233 Spring St, Dallas, TX 666666609 1969-03-11 101 Holyoke St, Dallas, TX 666666610 1970-05-23 198 Elm St, Philadelphia, PA 666666611 1977-06-21 213 Ball St, Philadelphia, PA 6666666121970-01-11 433 Main Street, Miami, FL 666666613 1980-05-21 196 Elm Street, Miami, FL B Bender 1966-01-14 6234 Lincoln, Chicago, IL 1966-04-16 1976 Boone Trace, Chicago, IL 1963-06-09 417 Hancock Ave, Chicago, IL 60-01-01 556 Washington, Chicago, IL 1964-08-22 1988 Windy Creek, Seattle, WA A Kramer HelgaC Pataki Naveen B Drew A Bacher