Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider two relations describing teams and players in a sports league:

  • teams(tid, tname): tid, tname are team-id and team-name, respectively
  • players(pid, pname, tid): pid, pname, and tid denote player-id, player-name 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 tname as 'MI'?

  • A.{ p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ p.tid = t.tid ∧ t.tname = 'MI')}
  • B.{ p.pname | p ∈ teams ∧ ∃t (t ∈ players ∧ p.tid = t.tid ∧ t.tname = 'MI')}
  • C.{ p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ t.tname = 'MI')}
  • D.{ p.pname | p ∈ teams ∧ ∃t (t ∈ players ∧ t.tname = 'MI')}

Answer: A

The correct query is { p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ p.tid = t.tid ∧ t.tname = 'MI')}.

The result must range over players, so p must be a tuple of players. A player qualifies if there exists a team tuple t that is the player's own team (p.tid = t.tid, the join condition) and whose name is 'MI'. Option A states exactly this.

Options B and D take p from teams, which has no pname attribute, so they do not even return player names. Option C drops the join condition p.tid = t.tid: as long as some team called 'MI' exists, it returns the name of every player in the league, whichever team they play for.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.