GATE CS 2019 Set 1 — Question 65
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.NAT+2 / -0MediumSelection & ProjectionRelational ModelDatabasesSet OperationsJoins
Databases → Relational Model → Joins
Last updated
Question
Consider the following relations P(X,Y,Z), Q(X,Y,T) and R(Y,V).P
Q
R
How many tuples will be returned by the following relational algebra query?Answer: ______________
| X | Y | Z |
|---|---|---|
| X1 | Y1 | Z1 |
| X1 | Y1 | Z2 |
| X2 | Y2 | Z2 |
| X2 | Y4 | Z4 |
| X | Y | T |
|---|---|---|
| X2 | Y1 | 2 |
| X1 | Y2 | 5 |
| X1 | Y1 | 6 |
| X3 | Y3 | 1 |
| Y | V |
|---|---|
| Y1 | V1 |
| Y3 | V2 |
| Y2 | V3 |
| Y2 | V2 |
Correct answer
1 to 1
Solution
The given relational algebra query is:Let's evaluate the two parts of the expression separately.Part 1:
Result of Part 1 - Result of Part 2
= {X2} - {X1}
= {X2}The final result is the set {X2}, which contains one tuple.Therefore, the number of tuples returned by the query is 1.
1.Cartesian Product (): This combines every tuple of P with every tuple of R.
2.Selection (): We need to find tuples from the cartesian product that satisfy both conditions:
-
P.Y = R.Y -
R.V = V2
R.V = V2:- (Y3, V2)
- (Y2, V2)
P.Y = R.Y condition:- For
Rtuple (Y3, V2), we need a tuple inPwithP.Y = Y3. There are no such tuples in P. - For
Rtuple (Y2, V2), we need a tuple inPwithP.Y = Y2. The tuple (X2, Y2, Z2) in P matches.
3.Projection (): We project the
X attribute from the result of the selection.- Projecting
Xfrom (X2, Y2, Z2, Y2, V2) gives {X2}.
1.Cartesian Product (): This combines every tuple of Q with every tuple of R.
2.Selection (): We need to find tuples that satisfy both conditions:
-
Q.Y = R.Y -
Q.T > 2
Q.T > 2:- (X1, Y2, 5)
- (X1, Y1, 6)
Q.Y = R.Y condition:- For
Qtuple (X1, Y2, 5), we need tuples inRwithR.Y = Y2. The matching tuples are (Y2, V3) and (Y2, V2). - For
Qtuple (X1, Y1, 6), we need a tuple inRwithR.Y = Y1. The matching tuple is (Y1, V1).
- (X1, Y2, 5, Y2, V3)
- (X1, Y2, 5, Y2, V2)
- (X1, Y1, 6, Y1, V1)
X attribute from the result of the selection.- Projecting
Xfrom the three resulting tuples gives {X1, X1, X1}. Since projection returns a set, duplicates are removed. - The result is {X1}.
Result of Part 1 - Result of Part 2
= {X2} - {X1}
= {X2}The final result is the set {X2}, which contains one tuple.Therefore, the number of tuples returned by the query is 1.
Continue learning with Success Tracker
A step still unclear? Work through it with support
Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.
AI-powered practice· Unlimited practice on eligible plans
- PYQs with solutions
- Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
- Practice that adapts
- Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
- AI doubt support
- Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.
Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.
This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.
More questions on Relational Model
2026 Set 2 Q15In the context of DBMS, consider the two sets T and S given below. | T | S | |---|---| | I:…2026 Set 2 Q20Consider concurrent execution of two transactions and in a DBMS, both of which access a…2026 Set 1 Q30Let and be the attributes of a relation in a relational schema. Let…2026 Set 1 Q31In the context of relational database normalization, which of the following statements is/are true?2026 Set 2 Q42In the context of schema normalization in relational DBMS, consider a set F of functional…