0% found this document useful (0 votes)
24 views2 pages

Exercises On Join Algos

The document contains 6 exercises involving relational algebra operations like join, sort-merge join, and division. The exercises estimate block accesses and costs for different join algorithms, show the runs created in each pass of sort-merge sorting, calculate block transfers for various join strategies, discuss memory requirements for different join algorithms, and ask to design a sort-based algorithm for relational division.

Uploaded by

abir Hal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Exercises On Join Algos

The document contains 6 exercises involving relational algebra operations like join, sort-merge join, and division. The exercises estimate block accesses and costs for different join algorithms, show the runs created in each pass of sort-merge sorting, calculate block transfers for various join strategies, discuss memory requirements for different join algorithms, and ask to design a sort-based algorithm for relational division.

Uploaded by

abir Hal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise 01:

Consider these relations with the following properties:


r(A, B, C) s(C, D, E)
30,000 tuples 60,000 tuples
25 tuples fit on 1 block 30 tuples fit on 1 block
a) Estimate the number of disk block accesses required for a natural join of r and s
using a nested-loop join if r is used as the outer relation.
b) Estimate the number of disk block accesses required for a natural join of r and s
using a block nested-loop join if s is used as the outer relation. Assume that there are
more than 2000 memory buffers available to facilitate this operation, where each
memory buffer can buffer one disk block.

Exercise 02:
Assume (for simplicity in this exercise) that only one tuple fits in a block and memory
holds at most 3 blocks. Show the runs created on each pass of the sort-merge
algorithm, when applied to sort the following tuples on the first attribute: (kangaroo, 17),
(wallaby, 21), (emu, 1), (wombat, 13), (platypus, 3), (lion, 8), (warthog, 4), (zebra, 11),
(meerkat, 6), (hyena, 9), (hornbill, 2), (baboon, 12).

Exercise 03:
Let relations r1(A, B,C) and r2(C, D, E) have the following properties:
r1 has 20,000 tuples,
r2 has 45,000 tuples,
5 tuples of r1 fit on one block, and 30 tuples of r2 fit on one block.
Estimate the number of block transfers required, using each of the following join
strategies for r1⨝r2 in the case of B=200 and B=850 (B is the buffer size in pages):
a. Nested-loop join.
b. Block nested-loop join.
c. Sort merge join.

Exercise 04:
Let r and s be relations with no indices, and assume that the relations are not sorted.
Assuming infinite memory, what is the lowest-cost way (in terms of I/O operations) to
compute r ⨝ s? What is the amount of memory required for this algorithm?

Exercise 05:
Suppose you need to sort a relation of 40 gigabytes, with 4-kilobyte blocks, using a
memory size of 40 megabytes. Suppose the disk transfer rate is 40 megabytes per
second.
a. Find the cost of sorting the relation, in seconds,
b. How many merge passes are required?

Exercise 06:
Design sort-based algorithm for computing the relational division operation.
Given two relations (tables): R(x,y) , S(y).
R and S : tables
x and y : column of R
y : column of S
R(x,y) div S(y) means gives all distinct values of x from R that are associated with all
values of y in S.

You might also like