Skip to main content

GATE CSE 2021Databases › SQLVerified

GATE CSE 2021 PYQ: A relation r ( A , B ) r(A, B) r ( A , B ) in a relational database has 1200 1200 1200 tuples. The attribute…

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)\vee(B=18)}(r) is ____________.

    Answer

    820

    Approach

    Use relational query selectivity estimation with inclusion-exclusion. Assume uniform distribution over the domains of A and B and independence. The expected output cardinality is the original tuple count times the probability that a randomly selected tuple satisfies the selection predicate.

    The standard selectivity estimation formula gives 820. The alternative 205 arises only if one enforces strict set semantics and first deduplicates the relation to at most 15×20 = 300 distinct (A,B) pairs, then applies the condition to those distinct tuples. However, the problem states that the relation has 1200 tuples and asks for an estimated query output cardinality, which in database query optimization assumes multiset/bag behavior (SQL table). Thus the expected answer is 820.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.