Sie sind auf Seite 1von 5

CS511: Design of Database Management Systems Fall 2005

Homework #1
Due: 3pm on Sep 21, 2005
Out: Sep 7, 2005

NOTE: Hand in your homework to TAs in 1117 SC on the due date between 2pm and
3pm. (since we do not have a class on that day.) For I2CS students, you need to email your
homework to Yoonkyong Lee.

Problem 1: E/R (10 pts)

The university has decided that the Champaign airport should be organized using a DBMS,
and you, being the DB expert, have been assigned the task of designing the database.
Using the following information, draw an ER diagram for the airport database. Be sure to
indicate the various attributes of each entity and relationship set; also specify the key and
participation constraints for relationship set.

• Every airplane has a registration number, and each airplane is of a specific model.
• The airport accommodates a number of airplane models, and each model is identified
by a model number (e.g., AK-13) and has a capacity and a weight.
• A number of technicians work at the airport. You need to store the name, SSN, address,
phone number, and salary of each technician.
• Each technician is an expert on one or more plane model(s), and his or her expertise
may overlap with that of other technicians. This information about technicians must
also be recorded.
• Traffic controllers must have an annual medical examination. For each traffic controller,
you must store the date of most recent exam.
• All airport employees (including technicians) belong to a union. You must store the
union membership number of each employee. You can assume that each employee is
uniquely identified by the social security number.
• The airport has a number of tests that are used periodically to ensure that airplanes are
still airworthy. Each test has a Federal Aviation Administration (FAA) test number,
a name, and a maximum possible score.
• The FAA requires the airport to keep track of each time a given airplane is tested by
a given technician using a given test. For each testing event, the information needed
is the date, the number of hours the technician spent doing the test, and the score the
airplane received on the test.

1
CS511: Homework #1 2

Problem 2: Normalization (15 pts, 5 pts each)

Consider the attribute set R = ABCDEGH and the functional dependencies set F = {AB
→ C, AC → B, AD → E, B → D, BC → A, E → G}. For each of the following attribute
set, do the following:

1. Compute the set of dependencies that hold over the set and write down a minimal
cover.

2. Is the relation containing these attributes in: i) 3NF, ii) BCNF? If no, then argue why
not.

3. Decompose the relation into a collection of BCNF relation, if it is not already in BCNF.

(a) ABCD, (b) ABCEG, (c) ACEH

Problem 3: SQL (10 pts)

Consider the following relational schema. An employee can work in more than one depart-
ment; the pctT ime field of the Works relation shows the percentage of time that a given
employee works in a given department.
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pctT ime : integer)
Dept(did: integer, dname: string, budget: real, managerid: integer)
Write the following queries in SQL:

1. [3 pts] Find the enames of managers who manage the departments with the largest
budgets.

2. [3 pts] If a manager manages more than one department, he or she controls the sum of
all the budgets for those departments. Find the managerids of managers who control
the largest amounts.

3. [4 pts] Find the enames of managers who manage only departments with budgets larger
than $1 million, but at least one department with budget less than $5 million.
CS511: Homework #1 3

10 20 30 80
I1

A B C

35 42 50 65 90 98
I2 I3

30* 31* 68* 69* 70* 79* 98* 99*100*105*


L1 L5 L8
36* 38* 51* 52* 56* 60* 94* 95* 96* 97*
L2 L4 L7
42* 43* 81* 82*
L3 L6

Figure 1: Tree for Problem 4

Problem 4: Indexing; B+ tree (20 pts, 5 pts each)

Consider the B+ tree index shown in Figure 1, which stores actual data records for data
entries. Each intermediate node can hold up to five pointers and four key values. Each leaf
can hold up to four records, and leaf nodes are doubly linked as usual, although these links
are not shown in the figure. Answer the following questions.

1. Name all the tree nodes (including leaf nodes) that must be fetched to answer the
following query: “Get all records with search key greater than 38.”

2. Show the B+ tree that would result from inserting a record with search key 109 from
the tree.

3. Show the B+ tree that would result from deleting the record with search key 81 from
the (original) tree.

4. Note that subtrees A, B, and C are not fully specified. Nonetheless, what can you infer
about the contents and the shape of these trees?
CS511: Homework #1 4

Problem 5: Query execution & optimization (25 pts)

1. Query execution: Join algorithm (15 pts)

Suppose we want to join two relations R and S on attribute A, then project the resulting
tuples on A. (Thus, we do not worry about other attributes.) The values of A in the
relations, listed in the order of relation scanning, are as follows:
R.A : 9, 7, 4, 6, 1, 5, 3, 8
S.A : 4, 3, 6, 8, 9, 3, 2, 1
Let’s execute the join with different algorithms below. For each algorithm, show the resulting
tuples (which have only one attribute A) in the order that they are produced.

1. [5 pts] Index join using an index on S.A.

2. [5 pts] Sort-merge join (assume sorting in increasing value order).

3. [5 pts] Nested-loop join using S as the outer relation.

2. Query optimization: Join order selection (10 pts)

Consider the join of relations R(a, b), S(b, c), T (c, d), and U (a, d), where R has 200 tuples,
S has 500 tuples, T has 1000 tuples, and U has 2000 tuples. Further, there are 100 values
of all attributes of all relations, except for attribute b, where V (R, b) = V (S, b) = 20.
Give the dynamic-programming table entries that evaluates all possible join orders allowing
left-deep trees only. And show what the best choice is.

Problem 6: Transaction management (20 pts, 10 pts


each)

Consider the following sequences of log records:

<START S>
<S,A,10>
<START T>
<T,B,20>
<S,C,30>
<T,D,40>
<COMMIT T>
<S,E,50>
<COMMIT S>
CS511: Homework #1 5

Describe the action of the recovery manager for each following assumption, including changes
to both disk and the log, if there is a crash and the last log record to appear on disk is
<S,E,50>.

1. Given log records are for undo-logging.

2. Given log records are for redo-logging.

Das könnte Ihnen auch gefallen