Relational Algebra & Calculus



Answer & solution
Answer: π_P.PRCODE(σ_S.CITY≠P.CITY((ρ_S SUPPLIER) ⋈_S.SCODE=X.SCODE (ρ_X SPPR) ⋈_X.PRCODE=P.PRCODE (ρ_P PROJECTS))). (no official key was published)
Rename SUPPLIER as S, SPPR as X and PROJECTS as P so that both CITY attributes can be referenced explicitly. Form J=(S ⋈_{S.SCODE=X.SCODE} X) ⋈_{X.PRCODE=P.PRCODE} P. Then return π_{P.PRCODE}(σ_{S.CITY≠P.CITY}(J)).
The joins establish that S actually supplies P through a shipment row. The selection keeps witnesses whose endpoint cities differ, and the projection returns the set of project codes having at least one such witness. A project may also have local suppliers and must still appear: the condition is existential, not a requirement that every supplier be out of town. A natural join over unrenamed relations would wrongly equate the two CITY attributes and suppress precisely the rows sought, so use explicit theta joins or rename the city columns before joining.