Cash-back offer from May 2nd to 7th, 2024: Get a flat 10% cash-back credited to your account for a minimum transaction of $50.Post Your Questions Today!

Question DetailsNormal
$ 33.00

CSC 352 / 452: DATABASE PROGRAMMING ASSIGNMENT #6 complete solutions correct answers key

Question posted by
Online Tutor Profile
request

CSC 352 / 452: Database Programming

assignment #6 (60 Points)

complete solutions correct answers key 

 

 

 

Unless prior arrangements are made, homework turned in late but within 24 hours of the due time will be graded at 75% credit, homework turned in between 24 and 48 hours will be graded at 50% credit, and homework turned in later than 48 hours will not be accepted.

 

1) (30 points)

Employees may move to different departments. We want to keep track of the departments where each employee has been. To do so we create a new table employee_history that keeps track of such history.

 

EMPLOYEE_HISTORY(EMPLOYEE_ID, EMPLOYEE_NAME, OLD_DEPARTMENT_NAME,

               NEW_DEPARTMENT_NAME, EFFECTIVE_DATE);

     

Write a trigger emp_hist_trg that monitors the employee table as follows.

·         When a row (record) is inserted into the employee table, the trigger automatically inserts a row (record) into the employee_history table in any situations.

o   The OLD_DEPARTMENT_NAME is always '(New Hire)'.

o   Find the new department name from the department table based on the new department_id.

If the new department_id is NULL, the NEW_DEPARTMENT_NAME will be 'TBA'.

 

·         When an employee changes his/her department (the old department_id is not equal to the new department_id), the trigger automatically inserts a row (record) into the employee_history table. (If both the old department_id and new department_id are NULL (from NULL department to NULL department), the trigger does not insert a row (record) into the employee_history table.)

o   Find the old department name from the department table based on the old department_id.

If the old department_id is NULL, the OLD_DEPARTMENT_NAME will be 'TBA'.

o   Find the new department name from the department table based on the new department_id.

If the new department_id is NULL, the NEW_DEPARTMENT_NAME will be 'TBA'.

 

·         The SYSDATE can be used in the EFFECTIVE_DATE column.

·         You can assume that the insert/update statements do not violate the integrity constraints between the department and employee tables.

·         No temporary table/view/procedure/function is allowed in your program.

  • You can only use the department, employee, and employee_history tables in your trigger. You will get a zero point if you use a different table (e.g., different table names, column names, or data types) in your trigger.

 

Step 1) (0 point) Create the employee_history table,

CREATE TABLE employee_history

(

      EMPLOYEE_ID             NUMBER(4)         NOT NULL,

EMPLOYEE_NAME                 VARCHAR2(50)      NOT NULL,

OLD_DEPARTMENT_NAME           VARCHAR2(100)     NOT NULL,

NEW_DEPARTMENT_NAME           VARCHAR2(100)     NOT NULL,

EFFECTIVE_DATE                DATE         NOT NULL

);

 

Step 2) Create the trigger emp_hist_trg.

You will get a zero point if you use a different trigger name.

 

Step 3) Test your trigger.

You need to create/run some test cases to check your trigger. You do not need to submit your test cases.

 

2) (30 points)

 

Create a trigger called job_min_sal_trg on the employee table. When an INSERT or UPDATE statement is issued against the employee table, the trigger is fired to ensure that the value of the SALARY column meets the criteria in the job_minimum_salary table. (For example, you can find that the minimum salary for a programmer is 800 from the job_minimum_salary table. Your trigger ensures that the salary for a programmer in the employee table is greater than or equal to 800.)

 

Step 1) (0 point) Create a table job_minimum_salary as follows.

 

CREATE TABLE job_minimum_salary

(

      JOB         VARCHAR2(50) PRIMARY KEY,

      SALARY      NUMBER(7, 2) NOT NULL

);

 

Step 2) (0 point) Populate the job_minimum_salary table as follows.

 

INSERT INTO job_minimum_salary VALUES ('ANALYST', 2000);

INSERT INTO job_minimum_salary VALUES ('DATABASE ADMINISTRATOR', 2500);

INSERT INTO job_minimum_salary VALUES ('PRESIDENT', 4800);

INSERT INTO job_minimum_salary VALUES ('PROGRAMMER', 800);

INSERT INTO job_minimum_salary VALUES ('PUBLIC ACCOUNTANT', 2400);

INSERT INTO job_minimum_salary VALUES ('SALESMAN', 1800);

INSERT INTO job_minimum_salary VALUES ('VICE PRESIDENT', 3800);

INSERT INTO job_minimum_salary VALUES ('TBA', 1800);

COMMIT;

 

Step 3) Create the trigger job_min_sal_trg.

 

·         The job_minimum_salary table is read-only. Your trigger cannot modify any rows in the job_minimum_salary table.

·         You must get the minimum salaries from the job_minimum_salary table in your program.

·         Hard coding, except the string'TBA', is not allowed in your program (e.g., IF job = 'SALESMAN' THEN v_min_sal = 1800 …).

·         If the job cannot be found from the job_minimum_salary table (e.g., Program Facilitator), the job is considered as “TBA”. (You need to check whether the salary is equal to or greater than the minimum salary for job = 'TBA'.)

·         If the salary is equal to or greater than the minimum salary of the corresponding job, the trigger does not change anything.

·         If the salary is less than the minimum salary of the corresponding job, the trigger increases the salary to the minimum salary of the corresponding job.

·         No temporary table/view/procedure/function is allowed in your program.

·         To avoid a mutating table error, please take a look examples on page 6, class handout 8.  (Hint: you cannot use some INSERT/UPDATE statements to modify the employee table in your trigger.)

·         You will get a zero point if you use a different trigger name.

·         If you modified the employee table created in Assignment #1, please delete and re-populate it.

 

Step 4) Test your trigger.

 

You need to create/run some test cases to check whether the values of the salary column in the employee table meet the criteria in the job_minimum_salary table in any situations. You do not need to submit your test cases.

 

 

Available Answer
$ 33.00

[Solved] CSC 352 / 452: DATABASE PROGRAMMING ASSIGNMENT #6 complete solutions correct answers key

  • This solution is not purchased yet.
  • Submitted On 18 Mar, 2016 01:59:05
Answer posted by
Online Tutor Profile
solution
CSC 352 / 452: Database Programming assignment #6 (60 Points) complete solutions correct answers key      Unless prior arrangements are made, homework turned in late but within 24 hours of the due time will be graded at 75% credit, homework turned in between 24 and 48 hours will be graded at 50% credit, and homework turned in later than 48 hours will not be accepted. 1) (30 points) Employees may move to different departments. We want to keep track of the departments where each employee has been. To do so we create a new table employee_history that keeps track of such history. EMPLOYEE_HISTORY(EMPLOYEE_ID, EMPLOYEE_NAME, OLD_DEPARTMENT_NAME,                NEW_DEPARTMENT_NAME, EFFECTIVE_DATE);       Write a trigger emp_hist_trg that monitors the employee table as follows. ·         When a row (record) is inserted into the employee table, the trigger automatically inserts a row (record) into the employee_history table in any situations. o   The OLD_DEPARTMENT_NAME is always '(New Hire)'. o   Find the new department name from the department table based on the new department_id. If the new department_id is NULL, the NEW_DEPARTMENT_NAME will be 'TBA'. ·         When an employee changes his/her department (the old department_id is not equal to the new department_id), the trigger automatically inserts a row (record) into the employee_history table. (If both the old department_id and new department_id are NULL (from NULL department to NULL department), the trigger does not insert...
Buy now to view the complete solution
attachment
Attachment
Other Similar Questions
User Profile
Exper...

CSC 352 / 452 ASSIGNMENT #2 | Complete Solution

DECLARE EmpName varchar2(30); hire varchar2(40); pay varchar2(40); ManName varchar(30); hire1 varchar2(40); sal varchar2(40); name varchar2(30); maxSal varchar2(40); depId NUMBER; de...
User Profile
Acade...

CSC 352 / 452: DATABASE PROGRAMMING ASSIGNMENT #1

CSC 352 / 452: DATABASE PROGRAMMING ASSIGNMENT #1 (60 POINTS) Due on Tuesday, 1/12/2016 at 11:59PM Unless prior arrangements are made, homework turned in late but within 24 hours of the due time will be graded at 75% credit...
User Profile
Acade...

CSC 352 / 452: DATABASE PROGRAMMING

CSC 352 / 452: DATABASE PROGRAMMING ASSIGNMENT #2 (60 POINTS) Due on Tuesday, 1/19/2016 at 11:59PM Unless prior arrangements are made, homework turned in late but within 24 hours of the due time will be graded at 75% credit...
User Profile
Acade...

CSC 352 / 452: DATABASE PROGRAMMING

CSC 352 / 452: DATABASE PROGRAMMING ASSIGNMENT #1 (60 POINTS) Due on Tuesday, 1/12/2016 at 11:59PM Unless prior arrangements are made, homework turned in late but within 24 hours of the due time will be graded at 75% credit...
User Profile
Acade...

CSC 352 / 452: DATABASE PROGRAMMING

CSC 352 / 452: DATABASE PROGRAMMING ASSIGNMENT #1 (60 POINTS) Due on Tuesday, 1/12/2016 at 11:59PM Unless prior arrangements are made, homework turned in late but within 24 hours of the due time will be graded at 75% credit...

The benefits of buying study notes from CourseMerits

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35