Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

3. Review together your differences and similarities.

Answered: 1 week ago

Question

2. How will the team select a leader?

Answered: 1 week ago