The GATE Grind

GATE 2012 CS (CS1) – Question 61

Databases · Relational Model: Relational Algebra, Tuple Calculus, SQL · 2 marks · Multiple choice

A(Id,Name,Age)={(12,Arun,60),(15,Shreya,24),(99,Rohit,11)}; B(Id,Name,Age)={(15,Shreya,24),(25,Hari,40),(98,Rohit,20),(99,Rohit,11)}; C(Id,Phone,Area)={(10,2200,02),(99,2100,01)}. How many tuples are returned?

SELECT A.Id FROM A
WHERE A.Age > ALL (SELECT B.Age FROM B WHERE B.Name='Arun')
  1. 4
  2. 3
  3. 0
  4. 1

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) 3

Explanation

No B row has name Arun, so the subquery is empty. A comparison quantified with ALL over the empty set is vacuously true. Consequently all three A rows are returned, giving 3, B. Their ages do not change that empty-set result.

More Relational Model: Relational Algebra, Tuple Calculus, SQL questions

All Relational Model: Relational Algebra, Tuple Calculus, SQL questions →