GATE DA 2024 | Question 31

NAT · 1 mark

Consider the following two tables named Raider and Team in a relational database maintained by a Kabaddi league. The attribute ID in table Team references the primary key of the Raider table, ID.

Raider
IDNameRaidsRaidPoints
1Arjun200250
2Ankush190219
3Sunil150200
4Reza150190
5Pratham175220
6Gopal193215
Team
CityIDBidPoints
Jaipur2200
Patna3195
Hyderabad5175
Jaipur1250
Patna4200
Jaipur6200

The SQL query described below is executed on this database:

SELECT *
FROM Raider, Team
WHERE Raider.ID=Team.ID AND City=“Jaipur” AND
RaidPoints > 200;

The number of rows returned by this query is ______.

Answer

3

Explanation

The condition Raider.ID=Team.ID turns the cross product into a join that pairs each Team row with the raider of the same ID. Of these pairs, keep only the Jaipur rows whose raider has more than 200 raid points:

  • Jaipur, ID 2: Ankush with 219 points, kept.
  • Jaipur, ID 1: Arjun with 250 points, kept.
  • Jaipur, ID 6: Gopal with 215 points, kept.

The Patna and Hyderabad rows fail the city test. Note that the comparison is strict, so a raider with exactly 200 points (Sunil) would not count, but he is in Patna anyway. The query returns 3 rows.

Answer: 3