Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Employees database only - https://dev.mysql.com/doc/employee/en/ 1. Create a procedure that adds a user. The procedure takes the five parameters of dept_no, birth_Date, first_name, last_name, and...

1 answer below »
Employees database only - https:
dev.mysql.com/doc/employee/en
1. Create a procedure that adds a user. The procedure takes the five parameters of dept_no,
irth_Date, first_name, last_name, and gender, as defined below.
The procedure consists of the steps:
- Generate a new employee number finding the highest emp_no and add one. I.e.,
new_emp_no = select max(emp_no) + 1 from employees
- Insert the new user into Table employees, where use CURDATE() for hire_date.
- Insert (new_emp_no, dept_no) into dept_emp, where use CURDATE() for from_date
and ' XXXXXXXXXX' for to_date.
You can test the procedure like "call addUser('d001', ' XXXXXXXXXX', 'John', 'Doe', 'M');". Then
check Tables employees and dept_emp whether the new user is added.
Evaluation (1) SQL query for the procedure and (2) Screen capture that shows that new user is added on Tables employees and dept_emp.
2. Add an attribute, "emp_num" (integer), on departments. The attribute will show the total
number of employees on the department. Then, update the field with the following SQL.
Check whether Table departments has co
ect total numbers of employees.
Evaluation: (1) SQL query for altering the table and (2) Screen capture that shows Table departments after updating.
3. Create a trigger, "add_emp_num", that update emp_num on department whenever a new
user is added. You can check the trigger by the query: SHOW TRIGGERS;
Evaluation: (1) SQL query for the trigger and (2) Screen capture that shows the result of "SHOW TRIGGERS"
4. Add a new user by using the procedure like "call addUser('d001', XXXXXXXXXX', 'John',
'Smith', 'M');". Then check whether emp_num is automatically increased by the trigger.
Evaluation: Screen capture that shows Table departments before and after adding a new user.
Answered Same Day Dec 03, 2021

Solution

Neha answered on Dec 07 2021
135 Votes
2 updat.sql
Alter table departments
add column emp_num int;
UPDATE departments,
(select dep.dept_no As dept_no, count(deemp.emp_no) As emp_numbers
from departments as dep inner join dept_emp as deemp on dep.dept_no=deemp.dept_no
group by dep.dept_name order by dept_no) emp
set departments.emp_num = emp.Emp_numbers
where...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here