SQL & Queries



Answer & solution
Answer: SELECT DISTINCT X.PCODE from the shipment/supplier/project join where both cities are DELHI. (no official key was published)
The shipment relation provides the association among a supplier, a part and a project. Join it to SUPPLIER on SCODE and to PROJECTS on PRCODE. The two city restrictions apply independently to supplier and project, not to PART.CITY.
SELECT DISTINCT X.PCODE
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 = 'DELHI' AND P.CITY = 'DELHI';
A qualifying shipment is a witness that the part satisfies the request. DISTINCT ensures each code appears once even if multiple suppliers or projects witness it, or several shipment records exist. No join to PART is necessary because the requested code is already present in SPPR, under the usual foreign-key consistency assumption. If parts must also exist despite unenforced references, add JOIN PART AS T ON T.PCODE=X.PCODE. SQL string comparison follows the database's collation; DELHI is the source's city literal.