Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SQL Consider the following two Relational Schema describing the EMPLOYEES and DE

ID: 3866130 • Letter: S

Question

SQL

Consider the following two Relational Schema describing the EMPLOYEES and DEPARTMENTS of some organization (assume all names are unique).

EMPLOYEES (EmployeeName, Salary, DeptName)

DEPARTMENTS (DeptName, ManagerName, City)

Define at schema level, a constraint (SQL Assertion) which specifies that none of the salaries of the employees of any department located in ‘San Francisco’ is more than the salary of any employee in the ‘Management’ department.


Consider the following two Relational Schema describing the EMPLOYEES and DEPARTMENTS of some organization (assume all names are unique). EMPLOYEES (EmployeeName, Salary, DeptName) DEPARTMENTS (DeptName, ManagerName, City) Write an SQL Trigger that reacts to the deletion of an employee who is a manager of a department by deleting that department and all its employees. HTML Editor

Explanation / Answer

CREATE ASSERTION check_salary AS CHECK ( NOT EXTISTS ( SELECT * FROM employees WHERE ( SELECT MAX(salary) FROM employees WHERE "DeptName" = 'San Fransisco' ) < ( SELECT MIN(salary) FROM employees WHERE "DeptName" = 'Management' ) ) );