Question
CREATE TABLE Employee( Fname VARCHAR(15) NOT NULL, Minit CHAR, Lname VARCHAR(15) NOT NULL, Ssn CHAR(9) NOT NULL, Bdate DATE, Address VARCHAR(30), Sex CHAR, Salary DECIMAL(10,2),
CREATE TABLE Employee(
Fname VARCHAR(15) NOT NULL,
Minit CHAR,
Lname VARCHAR(15) NOT NULL,
Ssn CHAR(9) NOT NULL,
Bdate DATE,
Address VARCHAR(30),
Sex CHAR,
Salary DECIMAL(10,2),
Super_ssn CHAR(9),
Dno INT NOT NULL,
PRIMARY KEY (Ssn));
CREATE TABLE Department (
Dname VARCHAR(15) NOT NULL,
Dnumber INT NOT NULL,
Mgr_ssn CHAR(9),
Mgr_start_date DATE,
PRIMARY KEY (Dnumber),
UNIQUE (Dname),
FOREIGN KEY (Mgr_ssn) REFERENCES Employee(Ssn));
CREATE TABLE Dept_Locations (
Dnumber INT NOT NULL,
Dlocation VARCHAR(15) NOT NULL,
PRIMARY KEY (Dnumber,Dlocation),
FOREIGN KEY (Dnumber) REFERENCES Department(Dnumber));
CREATE TABLE Project (
Pname VARCHAR(15) NOT NULL,
Pnumber INT NOT NULL,
Plocation VARCHAR(15),
Dnum INT NOT NULL,
PRIMARY KEY (Pnumber),
UNIQUE (Pname),
FOREIGN KEY (Dnum) REFERENCES Department(Dnumber));
CREATE TABLE Works_on (
Essn CHAR(9) NOT NULL,
Pno INT NOT NULL,
Hours DECIMAL(3,1) NOT NULL,
PRIMARY KEY (Essn,Pno),
FOREIGN KEY (Essn) REFERENCES Employee(Ssn),
FOREIGN KEY (Pno) REFERENCES Project(Pnumber));
CREATE TABLE Dependent (
Essn CHAR(9) NOT NULL,
Dependent_name VARCHAR(15) NOT NULL,
Sex CHAR,
Bdate DATE,
Relationship VARCHAR(8),
PRIMARY KEY (Essn,Dependent_name),
FOREIGN KEY (Essn) REFERENCES Employee(Ssn));
PL/SQL: stored procedure (encapsulating complex tasks) and cursor] Write a script that creates and executes a procedure named ComplexProc and then drops it. The procedure ComplexProc performs the following task: find employees whose salaries are higher than the average salary of all the employees in the same department and who have two or more dependents; then, for each found employee, check if the employee works more than a total of 10 hours a week on projects not controlled by his/her home department and, if so, print the employees full name (e.g., John Doe), salary, the number of dependents, the total number of hours on projects controlled by the home department, and the total number of hours on projects controlled by the other (i.e., non-home) departments. Format the output of the procedure to make it look nice.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started