0% found this document useful (0 votes)
2K views

Cisc 630 - HW2 PDF

The document outlines the assignments for the Database Systems course, including: 1) A recursive SQL query to find all subparts of a part with a given ID. 2) A SQL query using GROUP BY ROLLUP to aggregate counts of tuples by building, room number, and time slot. 3) SQL queries to find companies whose employees earn a higher average salary than a given company. 4) Relational algebra queries on a university schema to find students by courses taken and departments by instructor salaries. 5) Relational algebra queries using aggregation to find course sections taught by multiple instructors. 6) Construct an ER diagram for a hospital database tracking patients, tests, and doctors. 7)

Uploaded by

USVet96
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Cisc 630 - HW2 PDF

The document outlines the assignments for the Database Systems course, including: 1) A recursive SQL query to find all subparts of a part with a given ID. 2) A SQL query using GROUP BY ROLLUP to aggregate counts of tuples by building, room number, and time slot. 3) SQL queries to find companies whose employees earn a higher average salary than a given company. 4) Relational algebra queries on a university schema to find students by courses taken and departments by instructor salaries. 5) Relational algebra queries using aggregation to find course sections taught by multiple instructors. 6) Construct an ER diagram for a hospital database tracking patients, tests, and doctors. 7)

Uploaded by

USVet96
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment#2

MCIS 630 Database Systems (Fall, 2013) Total: 80 points Due: 10/27/2013 11:59PM 1. Consider the relational schema part(part-id, name, cost) subpart(part-id, subpart-id, count) A tuple (p1, p2, 3) in the subpart relation denotes that the part with part-id p2 is a direct subpart of the part with part-id p1, and p1 has 3 copies of p2. Note that p2 may itself have further subparts. Write a recursive SQL query that outputs the names of all subparts of the part with part-id P100. (6 points) 2. Consider the relation, r, shown below. Give the result of the following query: (6 points)
building Garfield Garfield Saucon Saucon Painter Painter room_number 359 359 651 550 705 403 time_slot_id A B A C D D course_id BIO-101 BIO-101 CS-101 CS-319 MU-199 FIN-201 sec_id 1 2 2 1 1 1

SELECT building, room_number, time_slot_id, count(*) FROM r GROUP BY ROLLUP (building, room_number, time_slot_id)

3. Consider an employee database with two relations employee(employee-name, street, city) works(employee-name, company-name, salary) where the primary keys are underlined. Write a query to find companies whose employees earn a higher salary, on average, than the average salary at First Bank Corporation. (10 points) a. Using SQL functions as appropriate. b. Without using SQL functions. 4. Write the following queries in relational algebra, using the university schema. (Appendix A, page 1271) (16 points, 4 points each) a. Find the names of all students who have taken at least one Comp. Sci. course. b. Find the IDs and names of all students who have not taken any course offering before Spring 2009. c. For each department, find the maximum salary of instructors in that department. You may assume that every department has at least one instructor. d. Find the lowest, across all departments, of the per-department maximum salary computed by the preceding query.

5. Using the university example, write relational-algebra queries to find the course sections taught by more than one instructor in the following ways: (8 points, 4 points each) a. Using an aggregate function. b. Without using any aggregate functions. 6. Construct an E-R diagram for a hospital with a set of patients and a set of medical doctors. Associate with each patient a log of the various tests and examinations conducted.(10 points) 7. Explain the distinction between disjoint and overlapping constraints. (4 points) 8. Explain the distinction between total and partial constraints. (4 points) 9. Consider the following set F of functional dependencies on the relation schema r(A,B,C,D,E,F): (16 points, 4 points each) ABCD BCDE BD DA a. Compute B+. b. Prove (using Armstrongs axioms) that AF is a superkey. c. Compute a canonical cover for the above set of functional dependencies F; give each step of your derivation with an explanation. d. Give a 3NF decomposition of r based on the canonical cover.

You might also like