GATE CS 2014 Set 2 — Question 64
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.MCQ+2 / -0.67MediumSQL JoinsSQLDatabasesSubqueries
Databases → SQL → SQL Joins
Last updated
Question
SQL allows duplicate tuples in relations, and correspondingly defines the multiplicity of tuples in the result of joins. Which one of the following queries always gives the same answer as the nested query shown below:
select * from R where a in (select S.a from S)
Correct answer
(C) [code]
Solution
The original query selects all tuples from where the attribute exists in the relation . The
This is a standard join. If has multiple rows with the same value, the result will contain multiple copies of the corresponding row from . This changes the multiplicity of the result compared to the original query.(B)
This removes duplicates from the result. However, the original relation might contain duplicate rows that satisfy the condition. The original query preserves duplicates present in , whereas
Here, the subquery
IN clause does not cause duplication of rows from even if contains duplicates of . It simply checks for existence.(A) select R.* from R, S where R.a=S.aThis is a standard join. If has multiple rows with the same value, the result will contain multiple copies of the corresponding row from . This changes the multiplicity of the result compared to the original query.(B)
select distinct R.* from R,S where R.a=S.aThis removes duplicates from the result. However, the original relation might contain duplicate rows that satisfy the condition. The original query preserves duplicates present in , whereas
DISTINCT would remove them. Thus, this is not equivalent.(C) select R.* from R, (select distinct a from S) as S1 where R.a=S1.aHere, the subquery
S1 contains only unique values of from . Joining with S1 ensures that each row in matches at most one row in S1. Therefore, rows in are not duplicated by the join, but existing duplicates in are preserved (since they each match the single corresponding entry in S1). This is equivalent to the IN clause behavior.(D) Syntax is invalid/non-standard.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 SQL
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…