SQL & Queries



Answer & solution
Answer: Join shipments to suppliers and projects, filter S.CITY <> P.CITY, and select the distinct three requested attributes. (no official key was published)
A row must describe an actual shipment rather than an arbitrary supplier/project combination. Use SPPR as the central relation and join the endpoint relations by their code keys. The supplier city is the first component; the destination project's city is the third.
SELECT DISTINCT S.CITY AS SUPPLIER_CITY,
X.PCODE,
P.CITY AS PROJECT_CITY
FROM SPPR AS X
JOIN SUPPLIER AS S ON S.SCODE = X.SCODE
JOIN PROJECTS AS P ON P.PRCODE = X.PRCODE
WHERE S.CITY <> P.CITY;The predicate removes local shipments, and DISTINCT collapses repeated triples caused by different suppliers, projects or shipment rows. PART.CITY is irrelevant: it is neither endpoint requested in the result. Aliases make the two CITY columns distinguishable. Classical relational problems normally assume nonnull attributes. In SQL, if a city is NULL, the inequality is UNKNOWN and the row is excluded; a different policy for unknown cities would require an explicit requirement and predicate.