Skip to content
Official PYQ · 2021

GATE CS 2021 Set 1 Q23 — Tuple Calculus and SQL

Explain with AI
A relation r(A,B)r(A, B) in a relational database has 12001200 tuples. The attribute AA has integer values ranging from 66 to 2020, and the attribute BB has integer values ranging from 11 to 2020. 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)\vee(B=18)}(r) is ____________.
View worked solution

Answer: 819 : 820 ; 205 : 205

To find the estimated number of tuples in the output of the selection query σ(A>10)∨(B=18)(r)\sigma_{(A > 10) \vee (B = 18)}(r), we assume a uniform and independent distribution of values for attributes AA and BB.

1. Probability of A>10A > 10:

  • The attribute AA has integer values ranging from 66 to 2020.
  • Total number of distinct values of A=20−6+1=15A = 20 - 6 + 1 = 15.
  • The values satisfying A>10A > 10 are {11,12,…,20}\{11, 12, \dots, 20\}, which gives 20−11+1=1020 - 11 + 1 = 10 values.
  • P(A>10)=1015=23P(A > 10) = \frac{10}{15} = \frac{2}{3}.

2. Probability of B=18B = 18:

  • The attribute BB has integer values ranging from 11 to 2020.
  • Total number of distinct values of B=20−1+1=20B = 20 - 1 + 1 = 20.
  • The only value satisfying B=18B = 18 is {18}\{18\}, which is 11 value.
  • P(B=18)=120P(B = 18) = \frac{1}{20}.

3. Combined Probability for the ∨\vee (OR) condition:

Since AA and BB are independently distributed:

P((A>10)∨(B=18))=P(A>10)+P(B=18)−P(A>10)⋅P(B=18)=23+120−(23×120)=40+3−260=4160\begin{aligned} P((A > 10) \vee (B = 18)) &= P(A > 10) + P(B = 18) - P(A > 10) \cdot P(B = 18) \\ &= \frac{2}{3} + \frac{1}{20} - \left(\frac{2}{3} \times \frac{1}{20}\right) \\ &= \frac{40 + 3 - 2}{60} = \frac{41}{60} \end{aligned}

4. Estimated Number of Tuples:

  • For 12001200 tuples: Estimated Tuples=1200×4160=820\text{Estimated Tuples} = 1200 \times \frac{41}{60} = 820
  • For 300300 tuples (alternative paper version): Estimated Tuples=300×4160=205\text{Estimated Tuples} = 300 \times \frac{41}{60} = 205

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Tuple Calculus and SQL questions