Wedgewood Pacific Exercises
In the Chapter 7 Review Questions, we introduced Wedgewood Pacific (WP) and
developed the WP database. Two of the tables that are used in the WP database are:
DEPARTMENT (DepartmentName, BudgetCode, OfficeNumber, DepartmentPhone)
EMPLOYEEE (EmployeeNumber, FirstName, LastName, Department, Position, Supervisor, OfficePhone, EmailAddress)
Assume that the relationship between these tables is M-M, and use the tables as the basis for your answers to Exercises 10B.68-10B.70.
10B.68 Code an Oracle Database trigger to enforce the constraint that an employee can never change his or her department.
10B.69 Code an Oracle Database trigger to allow the deletion of a department if it has only one employee. Assign the last employee to the Human Resources department. Assume the trigger in Review Question 10B.68 has not been created. HINT: Due to Oracle Database "mutating table" issues, the best solution here is to show a view that is a copy of the DEPARTMENT table and base the trigger on that view.
10B.70 Design a system of triggers to enforce the M-M relationship. Use Figure 10B-72 as an example, but assume that departments with only one employee can be deleted. Assign the last employee in a department to Human Resources. HINTS: You will need four triggers, but one of them is the solution to Review Question 10B.69. Also, you may need to create views for some or all of the remaining three triggers.