Relational Algebra · Databases
31 questions · asked in 19 of 27 years (2000–2026)
MCQ 27 · MSQ 1 · NAT 31-mark 17 · 2-mark 14
2000Questions per year2026
Questions 21–25 of 31
Consider the relations r1(P, Q, R) and r2(R, S, T) with primary keys P and R respectively. The relation contains 2000 tuples and contains 2500 tuples. The maximum size of the join is :
Answer: (A)
The only common attribute of r1 and r2 is R, and R is the primary key of r2. So no two tuples of r2 have the same R value.
Each tuple of r1 has one R value, so it matches at most one tuple of r2. It gives at most one tuple in the join. The join can have no more tuples than r1, which has 2000.
This maximum is reached when every R value in r1 appears in r2. The values 4500 and 5000 are impossible, and 2500 (the size of r2) is not the bound, since each r1 tuple adds at most one row.
Answer: (A)
Each tuple of r1 has one R value, so it matches at most one tuple of r2. It gives at most one tuple in the join. The join can have no more tuples than r1, which has 2000.
This maximum is reached when every R value in r1 appears in r2. The values 4500 and 5000 are impossible, and 2500 (the size of r2) is not the bound, since each r1 tuple adds at most one row.
Answer: (A)
Consider the relation enrolled (student, course) in which (student, course) is the primary key, and the relation paid (student, amount) where student is the primary key. Assume no null values and no foreign keys or integrity constraints. Assume that amounts 6000, 7000,8000,9000 and 10000 were each paid by 20% of the students. Consider these query plans (Plan 1 on left, Plan 2 on right) to "list all courses taken by students who have paid more than x."
A disk seek takes 4 ms, disk data transfer bandwidth is 300 MB/s and checking a tuple to see if amount is greater than x takes 10s . Which of the following statements is correct?
A disk seek takes 4 ms, disk data transfer bandwidth is 300 MB/s and checking a tuple to see if amount is greater than x takes 10s . Which of the following statements is correct?
Answer: (C)
Both plans compute the same thing: the courses of the enrolled students whose amount is more than x. Plan 1 applies the selection on amount before the join and Plan 2 after it, and pushing a selection below a join never changes the result. So (A) is false.
(B) is false. "Project on course" is a relational-algebra projection, which removes duplicate rows, so no course is listed twice.
Cost model: each probe of the index on student needs a disk seek of 4 ms, while checking one tuple against x takes only 10 s, 400 times less. So the number of index probes decides which plan is faster.
(D) is false. For x = 9000, only the students who paid 10000 (20% of them) pass the selection. Plan 1 probes the index for only these 20% of the paid tuples, while Plan 2 probes it for every paid tuple and filters afterwards. So Plan 1 is faster, not slower.
(C) is true. For x = 5000, every amount (6000 to 10000) is more than x, so the selection removes nothing and both plans make the same index probes. They differ only in the checks against x. Plan 1 checks each paid tuple once, during the sequential scan it makes anyway. Plan 2 checks every tuple of the join result, one for each course a paying student takes, and so does at least as many checks when each paying student is enrolled in a course. Plan 1 therefore never does more work and is the faster plan.
Answer: (C)
(B) is false. "Project on course" is a relational-algebra projection, which removes duplicate rows, so no course is listed twice.
Cost model: each probe of the index on student needs a disk seek of 4 ms, while checking one tuple against x takes only 10 s, 400 times less. So the number of index probes decides which plan is faster.
(D) is false. For x = 9000, only the students who paid 10000 (20% of them) pass the selection. Plan 1 probes the index for only these 20% of the paid tuples, while Plan 2 probes it for every paid tuple and filters afterwards. So Plan 1 is faster, not slower.
(C) is true. For x = 5000, every amount (6000 to 10000) is more than x, so the selection removes nothing and both plans make the same index probes. They differ only in the checks against x. Plan 1 checks each paid tuple once, during the sequential scan it makes anyway. Plan 2 checks every tuple of the join result, one for each course a paying student takes, and so does at least as many checks when each paying student is enrolled in a course. Plan 1 therefore never does more work and is the faster plan.
Answer: (C)
Let r be a relation instance with schema R = (A, B, C, D). We define and . Let where * denotes natural join. Given that the decomposition of r into and is lossy, which one of the following is TRUE?
Answer: (C)
Let . Take any tuple of r. Its projections are in r1 and is in r2. They agree on A, so they join to give in s. So every tuple of r is in s, that is .
The decomposition is lossy, so s also has extra (spurious) tuples. So the inclusion is proper: .
Example:
Every row of r also appears in s (shown in bold). The other two rows of s are spurious.
- (A) is false, since s is bigger than r.
- (B) , not r, because s has extra tuples.
- (D) joins on all four attributes, so it keeps exactly the tuples in both, which is r. So , not s.
Answer: (C)
The decomposition is lossy, so s also has extra (spurious) tuples. So the inclusion is proper: .
Example:
Every row of r also appears in s (shown in bold). The other two rows of s are spurious.
- (A) is false, since s is bigger than r.
- (B) , not r, because s has extra tuples.
- (D) joins on all four attributes, so it keeps exactly the tuples in both, which is r. So , not s.
Answer: (C)
A database table has 2000 records and occupies 80 disk blocks. Another table has 400 records and occupies 20 disk blocks. These two tables have to be joined as per a specified join condition that needs to be evaluated for every pair of records from these two tables. The memory buffer space available can hold exactly one block of records for and one block of records for simultaneously at any point in time. No index is available on either table.
If, instead of Nested-loop join, Block nested-loop join is used, again with the most appropriate choice of table in the outer loop, the reduction in number of block accesses required for reading the data will be
If, instead of Nested-loop join, Block nested-loop join is used, again with the most appropriate choice of table in the outer loop, the reduction in number of block accesses required for reading the data will be
Answer: (B)
Cost is counted in block accesses, with room for one block of each table in the buffer.
Nested-loop join: read the outer table once, and for every outer record read the whole inner table.
T2 as outer:
T1 as outer:
So T2 is the better outer table and the cost is 32020.
Block nested-loop join: read the outer table once, and for every outer block read the whole inner table.
T2 as outer:
T1 as outer:
The better choice is T2 as outer, with cost 1620.
Reduction .
Answer: (B)
Nested-loop join: read the outer table once, and for every outer record read the whole inner table.
T2 as outer:
T1 as outer:
So T2 is the better outer table and the cost is 32020.
Block nested-loop join: read the outer table once, and for every outer block read the whole inner table.
T2 as outer:
T1 as outer:
The better choice is T2 as outer, with cost 1620.
Reduction .
Answer: (B)
A database table has 2000 records and occupies 80 disk blocks. Another table has 400 records and occupies 20 disk blocks. These two tables have to be joined as per a specified join condition that needs to be evaluated for every pair of records from these two tables. The memory buffer space available can hold exactly one block of records for and one block of records for simultaneously at any point in time. No index is available on either table.
If Nested-loop join algorithm is employed to perform the join, with the most appropriate choice of table to be used in outer loop, the number of block accesses required for reading the data are
If Nested-loop join algorithm is employed to perform the join, with the most appropriate choice of table to be used in outer loop, the number of block accesses required for reading the data are
Answer: (C)
First we must decide which table goes in the outer loop. To keep block accesses low, the table with fewer records should be the outer one, because every outer record needs a pass over the inner table's blocks.
So, with table as the outer table (T2):
- For each of the records
- we need block accesses on the first table, which gives accesses.
- Add block accesses to read the outer table.
Hence the answer is
Correct answer: C.
Keep practising
Topics in Databases
ER ModelRelational Schema
Relational AlgebraYou are here
Tuple CalculusSQLIntegrity ConstraintsNormal FormFile SystemTransaction