Consider two relations describing \(π‘ππππ \) and \(ππππ¦πππ \) in aβ¦
2025
Consider two relations describingΒ \(π‘ππππ \) andΒ \(ππππ¦πππ \) in a sports league:
β’Β \(π‘ππππ (π‘ππ,π‘ππππ): π‘ππ, π‘πππe\) are team-id and team-name, respectively
β’ \(ππππ¦πππ (πππ, πππππ,π‘ππ): πππ, πππππ\), andΒ \(π‘ππ\) denote player-id, playername and the team-id of the player, respectively
Which ONE of the following tuple relational calculus queries returns the name of the players who play for the team having π‘ππππ as β²\(ππΌ\)β²?
Attempted by 101 students.
Show answer & explanation
Correct expression: { p.pname | p β players β§ βt (t β teams β§ p.tid = t.tid β§ t.tname = 'MI') }
Why this is correct:
The main variable p ranges over the players relation, so p.pname refers to a valid player name.
The existentially quantified tuple t ranges over teams and provides the team context to test.
The equality p.tid = t.tid links a player to their team, ensuring we only consider the player's own team.
The condition t.tname = 'MI' filters to the specific team named 'MI'. Combined, these return exactly the players who play for 'MI'.
Why the other expressions are wrong:
Expressions that bind the main variable to the teams relation and then try to return p.pname are invalid because team tuples do not have a player-name attribute.
Expressions that omit the equality p.tid = t.tid fail to link players to teams; such a query would return every player's name whenever any team named 'MI' exists, which is not the intended result.
Swapping the roles of the quantified relation (making the existential range over players while treating the main variable as a team) also mismatches attributes and produces incorrect or meaningless conditions.
Summary: The correct query binds the result variable to players, uses an existential team tuple to find a matching team by id, and filters that team by name 'MI'.
A video solution is available for this question β log in and enroll to watch it.