Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My tables create table s_employee( e_ssn number(9), super_ssn number(9), dept_num number(4) not null, firstname varchar2(30) not null, lastname varchar2(30) not null, middleint varchar2(1), street varchar2(30),

My tables

create table s_employee( e_ssn number(9), super_ssn number(9), dept_num number(4) not null, firstname varchar2(30) not null, lastname varchar2(30) not null, middleint varchar2(1), street varchar2(30), city varchar2(30), e_state varchar2(2), zip varchar2(5), b_day date, gender char, salary number(10), dependent char, constraint e_ssn_pk PRIMARY KEY (e_ssn), constraint dependent_ck CHECK (dependent IN('Y', 'N')));

CREATE TABLE s_dependent ( e_ssn number(9), d_ssn number(9), firstname varchar2(30), lastname varchar2(30), middleint varchar2(1), street varchar2(30), city varchar2(30), state varchar2(2), zip varchar2(5), b_day date, gender char, relationship varchar2(30), constraint dependent_d_ssn_pk PRIMARY KEY (d_ssn));

CREATE TABLE s_department ( dept_name varchar2(30) not null, dept_number number(4), mgr_ssn number(9), mgr_start_date date, constraint dept_number_pk PRIMARY KEY (dept_number), constraint dept_name_uq unique (dept_name), constraint mgr_ssn_fk FOREIGN KEY(mgr_ssn) references s_employee(e_ssn));

CREATE TABLE s_dept_locations ( dept_number number(8), dept_location varchar2(25), constraint dept_number_dept_name_pk PRIMARY KEY (dept_number, dept_location), constraint dept_number_fk FOREIGN KEY(dept_number) references s_department(dept_number));

CREATE TABLE s_project ( project_name varchar2(30) not null, project_number number(4), project_location varchar2(25), dept_number number(4), constraint project_number_pk PRIMARY KEY (project_number), constraint project_name_uq unique (project_name), constraint project_dept_number_fk FOREIGN KEY(dept_number) references s_department(dept_number));

CREATE TABLE s_employee_project ( e_ssn number(9), project_number number(4), hours number(4,1), constraint e_ssn_project_number_pk PRIMARY KEY (e_ssn, project_number), constraint e_ssn_fk FOREIGN KEY(e_ssn) references s_employee(e_ssn), constraint project_number_fk FOREIGN KEY(project_number) references s_project(project_number));

Query 2. For every project located in Stafford, list the project number, the controlling department number, and the department manager's last name, address, and birthdate.

Query 3. Make a list of all project numbers for projects that involve an employee whose last name is Smith either as a worker or as a manager of the department that controls the project.

Query 4. Retrieve the names of all employees who have two or more dependents.

Query 5. For each employee, retrieve the employee's first and last name and the first and last name of his or her immediate supervisor.

Query 6. Retrieve all employee SSNs.

Query 7. Retrieve all combinations of SSN and DEPARTMENT NAME.

Query 8. Retrieve all employees whose address is in Houston, Texas.

Query 9. Show the resulting salaries if every employee working on the ProductX project is given a 10% raise.

Query 10. Retrieve a list of employees and the projects they are working on, ordered by department and, within each department, ordered alphabetically by last name, first name.

Query 11. Retrieve the name of each employee who has a dependent with the same first name and same sex as the employee.

Query 12. Retrieve the social security numbers of all employees who work on project numbers 1, 2, or 3.

Query 13. Retrieve the names of all employees who do not have a supervisor.

Query 14. Find the sum of the salaries of all employees, the maximum salary, the minimum salary, and the average salary.

Query 15. Find the sum of the salaries of all employees of the Research department, as well as the maximum salary, the minimum salary, and the average salary in this department.

Query 16. Retrieve the total number of employees in the Research department.

Query 17. For each department, retrieve the department number, the number of employees in the department, and their average salary.

Query 18. For each project, retrieve the project number, the project name, and the number of employees who work on that project.

Query 19. For each project on which more than two employees work, retrieve the project number, the project name, and the number of employees who work on the project.

Query 20. For each project, retrieve the project number, the project name, and the number of employees from department 5 who work on the project.

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

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago