Question: Q 3 . [ 2 1 marks ] Consider the following two relations R 1 and R 2 : We would like to merge -

Q3.[21 marks] Consider the following two relations R1 and R2 :
We would like to merge-join R1 and R2 on attribute b. However, R1 is unsorted on b, so we have to
sort R1 before joining the relations. The records R2 are stored on attribute b in ascending order
sequentially from top to bottom. Assume 1 record fits into 1 block of memory. Please show how an
external sort-merge on R1 on the attribute b is conducted, by illustrating the following steps:
(a)[6 marks] Create sorted runs, assuming 4 blocks are allocated to the memory buffer.
Draw figures as in p.35 of Ch.12 lecture slides
There should be 2 runs. Label them sequentially as r1,r2.
(b)[12 marks] Merge the sorted runs created above via 2-way merge (p.36 of Ch.12 lecture
slides). The memory buffer has 3 blocks denoted as M1,M2 and 0, respectively.
Memory buffer
(blocks):
Show this process by stating the read/write operations in the form of
[ReadWrite ]x
For instance, "Read r1 to M1" stands for reading a block of r1 from disk to thememory block
M1, "Write M1 to 0" stands for writing the record in M1 to the output buffer, and "Write 0
to Disk" stands for writing the record in 0 to disk. The first seven operations are shown
as a reference:
Read r1 to M1
Read r2 to M2
Write M1 to 0
Write 0 to Disk
Read r1 to M1
Write M1 to 0
Write 0 to Disk
(c)[3 marks] Show the resulting joined relation.
Q 3 . [ 2 1 marks ] Consider the following two

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!