GATE / CS ARCHIVE

GATE CSE 1991 / QUESTION 12(b.i)

Suppliers serving both named projects

Database Management Systems · Relational Algebra & Calculus · Full GATE CSE 1991 paper

GATE 1991, Q12(b.i) Descriptive
Report issue

Relational Algebra & Calculus

Question 12(b.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for supplier codes supplying both projects PR1 and PR2.
Question 12(b.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for supplier codes supplying both projects PR1 and PR2.
Question 12(b.i), GATE 1991: SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for supplier codes supplying both projects PR1 and PR2.
Tap to enlarge
Answer & solution

Answer: π_SCODE(σ_PRCODE='PR1'(SPPR)) ∩ π_SCODE(σ_PRCODE='PR2'(SPPR)). (no official key was published)

First select shipments to PR1 and project their supplier codes: A=π_SCODE(σ_PRCODE='PR1'(SPPR)). Separately form B=π_SCODE(σ_PRCODE='PR2'(SPPR)). Both expressions have the same one-attribute schema, so set intersection is defined. The answer is A∩B.

Membership in the intersection requires a shipment witness to each project. The witnesses need not have the same part, quantity or shipment record. Selecting PRCODE='PR1' AND PRCODE='PR2' on a single tuple would be wrong because one shipment tuple cannot have two different project codes. Selecting with OR and projecting without intersection would also be wrong: it admits suppliers serving only one project. Under standard relational-algebra set semantics projection automatically eliminates duplicate supplier codes.

Original paper, page 7