0% found this document useful (0 votes)
159 views5 pages

Database HW3 Chap5

This document contains homework questions from Chapter 5 of a database systems textbook. It asks the student to write SQL queries to retrieve information from sample database schemas, define views on a sample database, and determine which queries and updates can be performed on a defined view. The questions cover concepts like nested queries, views, and operations allowed on views.

Uploaded by

kohsin.elsie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views5 pages

Database HW3 Chap5

This document contains homework questions from Chapter 5 of a database systems textbook. It asks the student to write SQL queries to retrieve information from sample database schemas, define views on a sample database, and determine which queries and updates can be performed on a defined view. The questions cover concepts like nested queries, views, and operations allowed on views.

Uploaded by

kohsin.elsie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Database System

Homework #3 (Chapter 5)

5.6. Specify the following queries in SQL on the database schema in Figure 1.2.

a. Retrieve the names and major departments of all straight-A students (students who have a
grade of A in all their courses).
b. Retrieve the names and major departments of all students who do not have a grade of A in
any of their courses.

1
5.7. In SQL, specify the following queries on the database in Figure 3.5 using the concept of nested
queries and concepts described in this chapter.

a. Retrieve the names of all employees who work in the department that has the employee
with the highest salary among all employees.
b. Retrieve the names of all employees whose supervisor’s supervisor has ‘888665555’ for
Ssn.
c. Retrieve the names of employees who make at least $10,000 more than the employee who
is paid the least in the company.

2
5.8. Specify the following views in SQL on the COMPANY database schema shown in Figure 3.5.
a. A view that has the department name, manager name, and manager salary for every
department.
b. A view that has the employee name, supervisor name, and employee salary for each
employee who works in the ‘Research’ department.
c. A view that has the project name, controlling department name, number of employees, and
total hours worked per week on the project for each project.
d. A view that has the project name, controlling department name, number of employees, and
total hours worked per week on the project for each project with more than one employee
working on it.

3
5.9. Consider the following view, DEPT_SUMMARY, defined on the COMPANY database in
Figure 3.6:
CREATE VIEW DEPT_SUMMARY (D, C, Total_s, Average_s)
AS SELECT Dno, COUNT(*), SUM(Salary), AVG(Salary)
FROM EMPLOYEE
GROUP BY Dno;

4
State which of the following queries and updates would be allowed on the view. If a query or
update would be allowed, show what the corresponding query or update on the base relations
would look like, and give its result when applied to the database in Figure 3.6.
a. SELECT *
FROM DEPT_SUMMARY;
b. SELECT D, C
FROM DEPT_SUMMARY
WHERE TOTAL_S > 100000;
c. SELECT D, AVERAGE_S
FROM DEPT_SUMMARY
WHERE C > (SELECT C FROM DEPT_SUMMARY WHERE D=4);
d. UPDATE DEPT_SUMMARY
SET D=3
WHERE D=4;
e. DELETE FROM DEPT_SUMMARY
WHERE C > 4;

You might also like