Docsity

Final Assignment with Problems - Biological Network Analysis | CIS 6930, Exams of Computer Science

Toggle sidebar
bg1
CIS6930 Spring 2009, Final Assignment
Due: 11:55pm, May 3, 2009 (Sunday), no late submissions will be accepted (i.e., no late
tokens can be used).
You should finish this assignment independently. Any discussions or exchange of ideas is
considered cheating.
Problem I. (25 pts) Some of you are familiar with the problem of computing spatial
distance histograms (SPH). The problem is stated as: given N points in a 2D space,
draw a histogram of all point-to-point distances. A histogram can be described by
three parameters: minimum distance l, maximum distance u, and resolution r. Therefore,
such a histogram consists of the counts of pairwise distances that fall into ranges [l, l+r),
[l+r, l+2r), [l+2r, l+3r), ….. Each such range is also called a bucket of the histogram.
Let us assume we store the coordinates of all points in a database table with the following
schema:
points(point_ID, x_coordinate, y_coordinate)
a (naïve) algorithm to solve the above problem is to calculate all point-to-point distances
(note that there are N(N-1)/2 such distances to calculate) and determine which bucket
each single distance belongs to, and increment the count of that bucket (by one).
Your task is to write a PLPGSQL function that computes the SDH of all the points in a
given “points” table. The function takes the maximum distance u, and resolution r as
parameters. Here let us assume the minimum distance l is always 0 therefore there is no
need to take it as another parameter. The output of the function should be something like
this:
Range | Count
-----------------------
[0, 10) | 100
[10, 20) | 122
[20, 30) | 79
…..
To get full credits for this problem, your code must compile and run in a PostgreSQL
server with, of course, the correct outputs. I will read the code to award partial credits. In
writing your function, you must follow the above schema of the “points” table.
Problem II. Consider the following schema:
Suppliers(sid, sname, address)
Parts(pid, pname, color)
Catalog(sid, pid, price)
Write the following queries. For each query, it is stated in which query language you
should express the query.
pf3

Partial preview of the text

Download Final Assignment with Problems - Biological Network Analysis | CIS 6930 and more Exams Computer Science in PDF only on Docsity!

CIS6930 Spring 2009, Final Assignment

Due: 11:55pm, May 3, 2009 (Sunday), no late submissions will be accepted (i.e., no late tokens can be used). You should finish this assignment independently. Any discussions or exchange of ideas is considered cheating. Problem I. (25 pts) Some of you are familiar with the problem of computing spatial distance histograms (SPH). The problem is stated as: given N points in a 2D space, draw a histogram of all point-to-point distances. A histogram can be described by three parameters: minimum distance l , maximum distance u , and resolution r. Therefore, such a histogram consists of the counts of pairwise distances that fall into ranges [ l , l+r ), [ l+r, l+2r ), [ l+2r, l+3r ), ….. Each such range is also called a bucket of the histogram. Let us assume we store the coordinates of all points in a database table with the following schema: points(point_ID, x_coordinate, y_coordinate) a (naïve) algorithm to solve the above problem is to calculate all point-to-point distances (note that there are N ( N - 1)/2 such distances to calculate) and determine which bucket each single distance belongs to, and increment the count of that bucket (by one). Your task is to write a PLPGSQL function that computes the SDH of all the points in a given “points” table. The function takes the maximum distance u , and resolution r as parameters. Here let us assume the minimum distance l is always 0 therefore there is no need to take it as another parameter. The output of the function should be something like this: Range | Count


[0, 10) | 100 [10, 20) | 122 [20, 30) | 79 ….. To get full credits for this problem, your code must compile and run in a PostgreSQL server with, of course, the correct outputs. I will read the code to award partial credits. In writing your function, you must follow the above schema of the “points” table. Problem II. Consider the following schema: Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, price) Write the following queries. For each query, it is stated in which query language you should express the query.

  1. (6 pts) Find the sids of suppliers who supply all blue parts. Write this query in relational algebra without using the division operator.
  2. (6 pts) Find the names of suppliers who supply exactly three parts. Write this query in relational algebra. You can use any operator.
  3. (7 pts) Find the names and pids of parts that are supplied by every supplier at a price of strictly less than 200 dollars. (If a supplier does not supply the part or if a supplier charges more than 200 dollars for it, the part should not be output.) Write this query in SQL;
  4. (6 pts) Find the name of the part(s) with the third highest price. Write this query in SQL without using the LIMIT or OFFSET keyword. Problem III. (25 pts) Given the following schemas: Employee (ssn, Name, dno, pid, sal, …); Department (dno, dname, mgr_id, …); Project (pid, startDate, endDate, …); and the following indexes built in the database:
  5. hash index on Department.dname
  6. B+-tree on Project.startDate
  7. hash index on Employee.dno
  8. B+-tree on Project.pid Obviously, one employee can work for at most one project. For the following SQL query, describe how the query optimization algorithm in a system R optimizer works to find the execution plan. You must list all intermediate plans generated in each step, in the way we did our example in class. SELECT Name, dname, startDate, endDate FROM Employee E, Department D, Project P WHERE startDate < ‘01/01/2007’ AND dname = “Finance” AND E.dno = D.dno AND E. pid = P.pid To calculate the costs of all the plans considered, make reasonable assumptions and use the following information: the Employee table has 20000 records in 1000 pages; the Department table has 20 records in 5 pages; the Project table has 2000 records in 200 pages; the selectivity of startDate < ‘01/01/2007’ is 50% and that for dname = ‘Finance’ is 0.05. Try to put as much detail as you can to get partial credits.