Consider the following relations and instances of relations: (where primary…

Consider the following relations and instances of relations: (where primary keys are bold)

Supply (sid, sname)

Parts (pid, pname, color)

Catalog (sid, pid)

If number of tuples returned by the above relational algebra query on the given instance of relations is n then n-2 is _______.

Answer: -2Key insight: the selection for color = 'violet' returns no tuples. Evaluate the selection σ_color='violet'(Parts): since the Parts table contains no part with…

Attempted by 5 students.

Show answer & explanation

Correct answer: -2

image.png

Key insight: the selection for color = 'violet' returns no tuples.

  • Evaluate the selection σ_color='violet'(Parts): since the Parts table contains no part with color 'violet', this selection returns 0 tuples.

  • Compute the cross product of Catalog with the empty result from the selection: Catalog × (empty) is empty (0 tuples).

  • Any projection of an empty relation remains empty.

  • Subtracting the Catalog tuples from an empty relation yields an empty relation (still 0 tuples).

Therefore the query returns n = 0 tuples, and n - 2 = -2.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…