Common data questions

Common Data for Questions 50 and 51:

Consider the following relations A, B and C:

Relation A:

Id Name Age
12 Arun 60
15 Shreya 24
99 Rohit 11

Relation B:

Id Name Age
15 Shreya 24
25 Hari 40
98 Rohit 20
99 Rohit 11

Relation C:

Id Phone Area
10 2200 02
99 2100 01

Shared with question 51.

Question

How many tuples does the result of the following relational algebra expression contain? Assume that the schema of A∪BA \cup B is the same as that of AA.

(A∪B)⋈A.Id>40∨C.Id<15C(A \cup B) \bowtie_{A.\text{Id} > 40 \lor C.\text{Id} < 15} C
Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2012 answer key

Solution

Compute the relation union A U B, then evaluate the theta-join condition (A.Id > 40 OR C.Id < 15) with relation C.

  1. Relation union A∪BA \cup B (set union removes duplicate rows):
  • Tuples in AA: (12, Arun, 60), (15, Shreya, 24), (99, Rohit, 11)
  • Tuples in BB: (15, Shreya, 24), (25, Hari, 40), (98, Rohit, 20), (99, Rohit, 11)
  • Distinct tuples in A∪BA \cup B (5 tuples):
    1. (12, Arun, 60)
    2. (15, Shreya, 24)
    3. (25, Hari, 40)
    4. (98, Rohit, 20)
    5. (99, Rohit, 11)
  1. Relation CC contains 2 tuples:
  • c1=(10,2200,02)c_1 = (10, 2200, 02) with Id=10\text{Id} = 10
  • c2=(99,2100,01)c_2 = (99, 2100, 01) with Id=99\text{Id} = 99
  1. Evaluating join condition (A.Id>40)∨(C.Id<15)(A.\text{Id} > 40) \lor (C.\text{Id} < 15) for each pair:
  • For tuple c1c_1 (C.Id=10C.\text{Id} = 10): Since 10<1510 < 15 is TRUE, the disjunction is TRUE for all 5 tuples of A∪BA \cup B. Yields 5 tuples.
  • For tuple c2c_2 (C.Id=99C.\text{Id} = 99): C.Id<15C.\text{Id} < 15 is FALSE. The condition holds only if A.Id>40A.\text{Id} > 40. In A∪BA \cup B, tuples with Id>40\text{Id} > 40 are (98, Rohit, 20) and (99, Rohit, 11). Yields 2 tuples.
  1. Total result tuples:
Total tuples=5+2=7\text{Total tuples} = 5 + 2 = 7
  1. This matches option (A).
Final answer

A

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

Source

Paper
GATE 2012 Computer Science and Information Technology (CS)
Question
50 of 65, printed as CS Q.50
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.