Professional Documents
Culture Documents
NG213 Data Structures - Project 1: Assignment 1: Query Processing and Optimization
NG213 Data Structures - Project 1: Assignment 1: Query Processing and Optimization
Assignment
NG213 Data Structures –1:Project
Query1 Processing and Optimization
Purpose:
The main purpose of this assignment is to help you practice query processing and optimization.
Questions:
1. Assume that you have the following schema:
Draw a relational algebra tree for the following query and use the heuristic rules to transform this
query into a more efficient form. Show each step and state the transformation rules used in the
process [25pts].
SELECT m.username,a.city
FROM mission AS m, path AS p, area AS a
WHERE a.nameOfArea = ‘xxx' AND a.areaID = p.areaID AND p.pathID = m.pathID
Regarding the area name (xxx), please add the name of the area that you live and then work
on the query.
2. Assume that for the given schema above, you have the following statistics:
− A hash index with no overflow on the primary key attributes username, missionId, droneId,
pathId and areaId;
− A clustering index on the foreign key attribute on username in the Mission table;
− A B+ tree index on the nameOfArea on Area table;
− The following is also known about the data:
nTuples(Mission) = Drop the first two digits from you ID and use the rest of it. For example if your
ID is 23xxxxx then the number of tuples in Mission is xxxxx
bFactor(Mission) = 40
nTuples(Path) = Drop the first three digits from you ID and use the rest of it. For example if your
ID is 234xxxx then the number of tuples in Path is xxxx
bFactor(Path) = 80
nTuples(Area) = 4,000
bFactor(Area)= 100
nDistinctusername(Mission) = 50
nLevelsusername (I) = 2
nLevelsnameOfArea (I) = 2
nlfBlocksnameOfArea(I) = 50
Calculate the cardinality and minimum cost for each of the following operations. Do not just
show the numeric answers, please show your approach clearly. You will get zero, if you only
show numeric answers.
1
b. 𝑃𝑎𝑡ℎ ⋈𝑎𝑟𝑒𝑎𝐼𝐷 𝐴𝑟𝑒𝑎 (Assume nBuffer=100) [25 pts]
c. 𝜋𝑢𝑠𝑒𝑟𝑛𝑎𝑚𝑒 (𝑀𝑖𝑠𝑠𝑖𝑜𝑛) [10 pts]
3. Given the following schedule, answer the following questions:
S0: R1(Z), R2(Z), R3(Y), R1(X), W1(X), R1(Z), R3(W), R2(X),W1(Y), W2(W)
a) Decide whether the given schedule is conflict serializable or not. Clearly explain why [25 pts].
b) If the given schedule is conflict serializable, what are all the equivalent serial schedules? [5 pts].
Submission Instructions:
You need to submit your assignment to ODTU class. Please note that you can submit scanned version
of your hand written answers. In that case, please make sure that your assignment is readable. If your
submission is not readable then you will automatically get zero.