Docsity

Oracle SQL Homework 4 for CSc 4710/6710, Spring 2003, Assignments of Deductive Database Systems

Toggle sidebar
bg1
CSc 4710/6710, Spring 2003
Homework 4: Due: 13 February, 2003 (Thursday)
1. Create the tables for the COMPANY database in Oracle SQL. Make sure that all
the constraints are enforced. The SQL statements can be downloaded from the
class Web page. The script given to you will not compile because of circular
references. You need to modify the script to make it work. Provide a solution with
the least number of changes to the schema given to you.
2. After creating the tables, populate the COMPANY database with the data. Again,
the SQL insert statements are given to you in the class Web page. Once again, the
script given to you will not execute due to circular references. Provide a solution
with fewest changes to the SQL statements provided to you. You should not make
any changes to the schema created in problem 1 to solve this problem.
3. (8.13 EN Text). Specify the following queries on the database schema shown in
Figure 7.5, using the relational operators discussed in this chapter. Also, show the
result of each query as it would apply to the database of Figure 7.6.
a. Retrieve the names of all employees in department 5 who work more than
10 hours per week on the ‘ProductX’ project.
b. List the names of all employees who have a dependent with the same first
name as themselves.
c. Find the names of all employees who are directly supervised by ‘Franklin
Wong’.
d. For each project, list the project name and the total hours per week (by all
employees) spent on the project.
e. Retrieve the names of all employees who work on every project.
f. Retrieve the names of all employees who do not work on any project.
g. For each department, retrieve the department name and the average salary
of all employees working in that department.
h. Retrieve the average salary of all female employees.
i. Find the names and addresses of all employees who work on at least one
project located in Houston but whose department has no location in
Houston.
j. List the last names of all department managers who have no dependents.
4. (8.14 EN Text). Specify the following additional queries on the database of
Figure 7.5 in SQL. Show the query results if each query is applied to the database
of Figure 7.6.
(a) For each department whose average employee salary is more than $30,000,
retrieve the department name and the number of employees working for that
department.
(b) Suppose that we want the number of male employees in each department
rather than all employees (as in Exercise 8.14 (a)). Can we specify this query
in SQL? Why or why not.

Partial preview of the text

Download Oracle SQL Homework 4 for CSc 4710/6710, Spring 2003 and more Assignments Deductive Database Systems in PDF only on Docsity!

CSc 4710/6710, Spring 2003 Homework 4: Due: 13 February, 2003 (Thursday)

  1. Create the tables for the COMPANY database in Oracle SQL. Make sure that all the constraints are enforced. The SQL statements can be downloaded from the class Web page. The script given to you will not compile because of circular references. You need to modify the script to make it work. Provide a solution with the least number of changes to the schema given to you.
  2. After creating the tables, populate the COMPANY database with the data. Again, the SQL insert statements are given to you in the class Web page. Once again, the script given to you will not execute due to circular references. Provide a solution with fewest changes to the SQL statements provided to you. You should not make any changes to the schema created in problem 1 to solve this problem.
  3. (8.13 EN Text). Specify the following queries on the database schema shown in Figure 7.5, using the relational operators discussed in this chapter. Also, show the result of each query as it would apply to the database of Figure 7.6. a. Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. b. List the names of all employees who have a dependent with the same first name as themselves. c. Find the names of all employees who are directly supervised by ‘Franklin Wong’. d. For each project, list the project name and the total hours per week (by all employees) spent on the project. e. Retrieve the names of all employees who work on every project. f. Retrieve the names of all employees who do not work on any project. g. For each department, retrieve the department name and the average salary of all employees working in that department. h. Retrieve the average salary of all female employees. i. Find the names and addresses of all employees who work on at least one project located in Houston but whose department has no location in Houston. j. List the last names of all department managers who have no dependents.
  4. (8.14 EN Text). Specify the following additional queries on the database of Figure 7.5 in SQL. Show the query results if each query is applied to the database of Figure 7.6. (a) For each department whose average employee salary is more than $30,000, retrieve the department name and the number of employees working for that department. (b) Suppose that we want the number of male employees in each department rather than all employees (as in Exercise 8.14 (a)). Can we specify this query in SQL? Why or why not.