You are on page 1of 3

Department of Information Systems IS312: Database Systems II

Faculty of Computers and Information Midterm Exam - Spring 2015


Cairo University 30th of March, 2015
ANSWERS
Dr. Mohamed Elwakil Duration: 1 hour
Marks: 10 points
Exam Instructions
1. Remember to fill in your identifying information (‫)أكتب اسمك باللغة العربية‬
2. Answer all questions, following the same order and in the provided space.
3. This is a closed-book test. You are not allowed to use any material.
4. Provide only one answer to any question.

Answer the following questions [Q1:Q4: 1 point each – Q5:Q7: 2 points each]:
1. What are the advantages of the hashing access path? What are the disadvantages of the
hashing access path?
Advantages of hashing: fastest access path, highly parallelizable
Disadvantages of hashing: inefficient storage, sensitive to data skewing
2. What are the four steps of query execution? What is the input of query execution? What
is the output of query execution?
The four steps:
1. Scanning, parsing and validating
2. Query optimization
3. Query code generation
4. Actual execution (runtime database processing)
Input: SQL Query
Output: Result set (rows and columns
5. What are the advantages of the sorting-based algorithms? What are the
disadvantages of the sorting-based algorithms?
Advantages of the sorting-based algorithms: efficient, suitable for already sorted data or
when sorted output is required.
Disadvantages of the sorting-based algorithms: if the data is not sorted and sorting is not
required, sorting-based algorithms will necessitate expensive sorting.
6. What is the difference between pipelining and stream-based processing?
No difference. They are the same thing!
7. Assume a join operation (R ⋈ S) that will be carried out using the nested-loop join
algorithm. Table R consists of 14 blocks. Table S consists of six blocks. There are three
memory buffers. Calculate the cost (in terms of blocks) of the best way to execute this
join operation.
The best way is to have the smaller table (S) in the outer loop.
The cost: bR + ⌈bR/(nb-2)⌉* bS + ((js*|R|*|S|/bfrRS)
The cost: 14 + 14/1 * 6 + ((js*|R|*|S|/bfrRS)
The cost: 98 + ((js*|R|*|S|/bfrRS)
8. Is it practical to apply heuristic optimizations after cost-based optimization? Why or
why not?
No, it is not. Heuristic optimizations should be applied before cost-based optimization. In
heuristic optimization, the order of operations is decided and in cost-based optimization,
which algorithm to carry out the operation is selected.
9. Are the two query trees in the below figure equivalent? If yes, then what is their SQL
query? If no, then indicate the reason.
They are equivalent.
The SQL query is SELECT lname FROM employee, works_on, project WHERE (pname =
‘aquarius’) and (pnmuber=pno) and (essn=ssn) and (bdate > ‘1957-12-31’);
Dr. Mohamed Elwakil Dr. Ehab Ezzat

You might also like