The GATE Grind

GATE 2015 CS (CS3) – Question 29

Databases · Relational Model: Relational Algebra, Tuple Calculus, SQL · 1 mark · Multiple choice

Cinema(theater,address,capacity) stores theaters. Complete the query to always return addresses of maximum-capacity theaters, assuming non-NULL capacities:

SELECT P1.address FROM Cinema P1
-- clause here
  1. WHERE P1.capacity >= ALL (SELECT P2.capacity FROM Cinema P2)
  2. WHERE P1.capacity >= ANY (SELECT P2.capacity FROM Cinema P2)
  3. WHERE P1.capacity > ALL (SELECT MAX(P2.capacity) FROM Cinema P2)
  4. WHERE P1.capacity > ANY (SELECT MAX(P2.capacity) FROM Cinema P2)

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) WHERE P1.capacity >= ALL (SELECT P2.capacity FROM Cinema P2)

Explanation

A row has maximum capacity exactly when its capacity is at least every capacity in the relation, giving A. ANY admits rows merely exceeding the minimum. The strict greater-than comparisons with the maximum exclude every row, including tied maxima.

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

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