GateAI
Relational Model and SQL

GATE CSE 2014 Set 2 · Q54

MCQ2 marksMedium

Time

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)

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) select R.* from R,(select distinct a from S) as S1 where R.a=S1.a

Relational Model and SQL

The given query: ```sql select * from R where a in (select S.a from S) ``` checks for membership in the subquery result. Even if S has duplicate values for column a, a tuple in R is output exactly once for each of its occurrences in R, with no multiplication of multiplicity caused by duplicate matching values in S.

Now analyzing the options:

  • Option (A):select R.* from R, S where R.a=S.a performs a standard join. If a value of R.a appears mm times in S, that tuple from R will be duplicated mm times in the output.

  • Option (B):select distinct R.* from R,S where R.a=S.a removes duplicate tuples of R, which alters the original multiplicity of identical tuples that were already present in R.

  • Option (C):select R.* from R, (select distinct a from S) as S1 where R.a=S1.a eliminates duplicate values from S first. Joining with this deduplicated subquery ensures each tuple of R matches at most once, preserving the exact multiplicity of tuples in R as in the original IN subquery.

  • Option (D): Not valid standard SQL syntax.

Thus, (C) is the correct option.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Relational Model and SQL previous year question is Q54 of the GATE CSE 2014 Set 2 paper. Find more GATE CSE PYQs on Relational Model and SQL in Databases, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Relational Model and SQL PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Relational Model and SQL in GATE CSE

Relational Model and SQL has 15 GATE CSE PYQs across 12 papers from 2011 to 2026. 8 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2014 Set 2.

How GATE tests Relational Model and SQL

More from GATE CSE 2014 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 2 · Q54 · MCQ

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)

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.