Skip to content
Official PYQ · 2012

GATE CS 2012 Q50 — Relational Model: Relational Algebra

Explain with AI

Consider the following relations A,BA, B and C:C:

IDNameAge12Arun6015Shreya2499Rohit11AIDNameAge15Shreya2425Hari4098Rohit2099Rohit11BIDPhoneArea1022000299210001C\overset{\text{A}}{\begin{array}{|c|c|c|} \hline \text{ID} & \text{Name} & \text{Age} \\ \hline\text{12}& \text{Arun} & \text{60} \\ \hline\text{15}& \text{Shreya} & \text{24} \\ \hline\text{99}& \text{Rohit} & \text{11} \\ \hline \end{array}} \qquad \overset{\text{B}}{\begin{array}{|c|c|c|} \hline \text{ID} & \text{Name} & \text{Age} \\ \hline \text{15}& \text{Shreya} & \text{24} \\ \hline\text{25}& \text{Hari} & \text{40} \\ \hline\text{98}& \text{Rohit} & \text{20} \\ \hline\text{99}& \text{Rohit} & \text{11} \\ \hline \end{array}}\qquad \overset{\text{C}}{\begin{array}{|c|c|c|} \hline \text{ID} & \text{Phone} & \text{Area} \\ \hline \text{10}& \text{2200} & \text{02} \\ \hline\text{99}& \text{2100} & \text{01} \\ \hline \end{array}}

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.Id > 40 \vee C.Id < 15} C

Choose one option
View worked solution

Answer: A

First, we find the relation R=Aext∪ BR = A ext{ } \cup \text{ } B. Since union eliminates duplicate tuples, we get:

R=A∪B=IDNameAge12Arun6015Shreya2425Hari4098Rohit2099Rohit11R = A \cup B = \begin{array}{|c|c|c|} \hline \text{ID} & \text{Name} & \text{Age} \\ \hline 12 & \text{Arun} & 60 \\ \hline 15 & \text{Shreya} & 24 \\ \hline 25 & \text{Hari} & 40 \\ \hline 98 & \text{Rohit} & 20 \\ \hline 99 & \text{Rohit} & 11 \\ \hline \end{array}

Relation CC is given as:

C=IDPhoneArea1022000299210001C = \begin{array}{|c|c|c|} \hline \text{ID} & \text{Phone} & \text{Area} \\ \hline 10 & 2200 & 02 \\ \hline 99 & 2100 & 01 \\ \hline \end{array}

The join condition is R.ID>40∨C.ID<15R.\text{ID} > 40 \lor C.\text{ID} < 15. We evaluate this condition for each pair in the Cartesian product R×CR \times C:

  1. For the tuple in CC with ID=10\text{ID} = 10: Since 10<1510 < 15, the condition C.ID<15C.\text{ID} < 15 is True. Thus, the disjunction is satisfied for all 55 tuples of RR. This contributes 55 tuples to the result.
  2. For the tuple in CC with ID=99\text{ID} = 99: Since 99≮1599 \not< 15, the condition C.ID<15C.\text{ID} < 15 is False. The overall condition simplifies to R.ID>40R.\text{ID} > 40. The tuples in RR satisfying this are those with ID=98\text{ID} = 98 and ID=99\text{ID} = 99. This contributes 22 tuples to the result.

Total number of tuples in the result = 5+2=75 + 2 = 7.

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

Published
Report a correction
Keep exploringMore Relational Model: Relational Algebra questions