Question

A relation r(A,B)r(A, B) in a relational database has 1200 tuples. The attribute AA has integer values ranging from 6 to 20, and the attribute BB has integer values ranging from 1 to 20. Assume that the attributes AA and BB are independently distributed.

The estimated number of tuples in the output of σ(A>10)∨(B=18)(r)\sigma_{(A > 10) \lor (B = 18)}(r) is __________

Official answer and solution
Accepted answers
819 to 820, or 205
From
Official GATE 2021 answer key
About the official key

GATE accepted either range [819, 820] (based on standard independent disjunction selectivity) or 205 (which corresponds to an alternate interpretation where the condition was read as conjunction or restricted domain).

Note on this question

Official answer key accepts either range 819.0 to 820.0 or 205.0 to 205.0.

Solution

Calculate individual selectivities of the conditions on A and B, then use independent probability for logical OR.

Total tuples in relation r(A,B)r(A, B) is N=1200N = 1200.

  • Attribute AA has integer values ranging uniformly from 6 to 20, comprising 20−6+1=1520 - 6 + 1 = 15 distinct values.
  • The condition (A>10)(A > 10) covers values {11,12,…,20}\{11, 12, \dots, 20\}, which is 20−11+1=1020 - 11 + 1 = 10 values.
  • The selectivity of (A>10)(A > 10) is s(A)=1015=23s(A) = \frac{10}{15} = \frac{2}{3}.
  • Attribute BB has integer values ranging uniformly from 1 to 20, comprising 20 distinct values.
  • The condition (B=18)(B = 18) matches 1 value out of 20, with selectivity s(B)=120s(B) = \frac{1}{20}.

Because attributes AA and BB are independently distributed, the selectivity of the disjunction (A>10)∨(B=18)(A > 10) \lor (B = 18) is:

s(A∨B)=s(A)+s(B)−s(A)⋅s(B)=23+120−(23×120)=40+3−260=4160s(A \lor B) = s(A) + s(B) - s(A) \cdot s(B) = \frac{2}{3} + \frac{1}{20} - \left(\frac{2}{3} \times \frac{1}{20}\right) = \frac{40 + 3 - 2}{60} = \frac{41}{60}

The estimated number of tuples in the output is:

Tuples=1200×4160=20×41=820\text{Tuples} = 1200 \times \frac{41}{60} = 20 \times 41 = 820

(Or 819 if computed with slight precision variations).

Final answer

820

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2021 Computer Science and Information Technology (CS, Set-1)
Question
33 of 65, printed as CS Q.23
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.