Consider the following instance of a relation District – Which district names…

2024

Consider the following instance of a relation District –

image.png

Which district names will be returned by the following relational algebra expression?
πₙₐₘₑ (σₙₐₘₑ≠"AJ" (District)) − [πₙₐₘₑ (σₚₒₚᵤₗₐₜᵢₒₙ>5 (District)) ∩ πₙₐₘₑ (σₙₐₘₑ="AJ" (District))]

Answer: A. JA,MMConcept: Selection σₙₐₘₑ(R) keeps only the tuples of relation R that satisfy the predicate; projection πₙₐₘₑ(R) then extracts just that attribute from the…

  1. A.

    JA,MM

  2. B.

    JA

  3. C.

    JA,AJ

  4. D.

    AJ

  5. E.

    Question not attempted

Attempted by 317 students.

Show answer & explanation

Correct answer: A

Concept: Selection σₙₐₘₑ(R) keeps only the tuples of relation R that satisfy the predicate; projection πₙₐₘₑ(R) then extracts just that attribute from the surviving tuples (duplicates removed). For two such projected sets, intersection (∩) keeps tuples common to both, and set difference (A − B) keeps the tuples of A that are absent from B.

  1. Left operand: πₙₐₘₑ (σₙₐₘₑ≠"AJ" (District)) — σₙₐₘₑ≠"AJ" keeps every row whose name is not "AJ". From District {JA:10, AJ:50, MM:5}, this is {JA, MM}. πₙₐₘₑ of this is {JA, MM}.

  2. First factor of the bracket: πₙₐₘₑ (σₚₒₚᵤₗₐₜᵢₒₙ>5 (District)) — σₚₒₚᵤₗₐₜᵢₒₙ>5 keeps every row with population greater than 5. Both JA (10) and AJ (50) satisfy this; MM (5) does not, since 5 is not strictly greater than 5. So the selection is {JA, AJ}, and πₙₐₘₑ gives {JA, AJ}.

  3. Second factor of the bracket: πₙₐₘₑ (σₙₐₘₑ="AJ" (District)) — σₙₐₘₑ="AJ" keeps only the row named "AJ", i.e. {AJ}. πₙₐₘₑ gives {AJ}.

  4. Intersect the two projected sets: {JA, AJ} ∩ {AJ} = {AJ}.

  5. Subtract from the left operand: {JA, MM} − {AJ}. Since "AJ" is not an element of {JA, MM}, removing it changes nothing, leaving {JA, MM}.

Cross-check: πₙₐₘₑ (σₙₐₘₑ="AJ" (District)) can never contain any name other than "AJ", so the bracket’s intersection is always a subset of {AJ} — at most {AJ}, never more, regardless of any population value. The left operand πₙₐₘₑ (σₙₐₘₑ≠"AJ" (District)) excludes "AJ" by construction. Subtracting a set that is at most {AJ} from a set that never contains "AJ" removes nothing, so the expression evaluates to {JA, MM} as long as AJ exists in District — independent of the exact population figures. Final result: {JA, MM}.

Explore the full course: Up Lt Grade Assistant Teacher 2025

Loading lesson…