Anda di halaman 1dari 2

NUST National University of Sciences and Technology (NUST) School of Electrical Engineering and Computer Science (SEECS)

MS IT - 12, Advanced Database Concepts Second Assignment, November 2011 Student Name:. Roll No:... Marks 200 This assignment is due on Wednesday 7th December, 2011. The solution to the assignment should be handed in the Instructors Office. Please attach this sheet to the solution as a header and make sure that your name and page number appear on each page of the solution. To get good marks you must explain your solution.

Question 1: Answer to the point. Consider the join RR.a=S.b S, given the following information about the relations to be joined. The cost metric is the number of disk I/Os unless otherwise noted, and the cost of writing out the result should be uniformly ignored Relation R contains 10,000 tuples and has 10 tuples per block Relation S contains 2000 tuples and also has 10 tuples per block Attribute b = 10 byte of S is the primary key for S Both relations are stored as simple heap files Neither relation has any indexes built on it Block size B= 1024 bytes blocks 52 main memory buffers are available 1. What is the cost of joining R and S using a sort-merg join? 2. If clustered indexes on R.a and S.b are available with the block pointer is P = 5 bytes long, what is the cost of joining R and S using a index-based join? 3. How many tuples does the join of R and S produces, at most, and how many blocks are required to store the result of the join back on disk? Question 2: Answer to the point. Consider the following relational schema. The schema captures information about employees, and departments. Emp (eid: integer (8), ename: char (30 bytes), did: integer (8), sal: integer (8), hobby: char (20)) Dept (did: integer (8), dname: char(30), floor: integer (8), phone: char(10)) You are given the following information: The Emp.eid attribute is a primary key. The file is physically sorted on Emp.eid. The Emp relation contains r = 300,000 fixed-length records. The Dept.did attribute is a primary key. The file is stored as a simple heap file. The Dept relation contains r = 2000 fixed-length records. There are 52 main memory buffers (M). Disk block size B= 1024 bytes.

A primary index is available on Emp.eid. The block pointer is P = 5 bytes long. A B+ tree index on Dept.did is available and each node is 69 percent full. A record pointer is Pr = 7 bytes and a block pointer is 5 bytes long. Consider the following SQL query: SELECT E.eid, E.ename, D.dname FROM Emp E, Dept D WHERE E.did = D.did Using cost estimates, compute the following different execution plans. Consider the importance of join order in computing the cost. 1. What is the joining cost using nested loops join? 2. What is the joining cost using sort-merg join? 3. What is the joining cost using index-based join? 4. Select the optimized plan for the execution the query.

Anda mungkin juga menyukai