ADC hw3
ADC hw3
Priyanka Voleti
2. Find the sids of suppliers who supply some red or green part.
Relational Algebra:
πsid (Catalog ▷◁ σcolor=′ red′ ∨color=′ green′ (P arts))
Tuple Relational Calculus (TRC):
{S.sid | Suppliers(S)∧∃C∃P (Catalog(C)∧P arts(P )∧C.sid = S.sid∧C.pid = P.pid∧(P.color =′ red′ ∨P.color =′ green′ ))}
Domain Relational Calculus (DRC):
{sid | ∃sid, pid (Catalog(sid, pid, cost) ∧ (∃pname(P arts(pid, pname,′ red′ ) ∨ P arts(pid, pname,′ green′ ))))}
3. Find the sids of suppliers who supply some red part and some green part.
Relational Algebra:
πsid (πsid (Catalog ▷◁ σcolor=′ red′ (P arts))
∩ πsid (Catalog ▷◁ σcolor=′ green′ (P arts)))
Tuple Relational Calculus (TRC):
{S.sid | Suppliers(S) ∧ ∃C1∃P 1∃C2∃P 2 (Catalog(C1) ∧ P arts(P 1)
∧ Catalog(C2) ∧ P arts(P 2) ∧ C1.sid = S.sid ∧ C2.sid = S.sid
∧ C1.pid = P 1.pid ∧ C2.pid = P 2.pid ∧ P 1.color =′ red′ ∧ P 2.color =′ green′ )}
Domain Relational Calculus (DRC):
{sid | ∃pid1, pid2 (Catalog(sid, pid1, cost1) ∧ Catalog(sid, pid2, cost2)
∧ (∃pname1P arts(pid1, pname1,′ red′ )) ∧ (∃pname2P arts(pid2, pname2,′ green′ ))
1
4. Find the sids of suppliers who supply every part.
Relational Algebra:
πsid (Suppliers) ÷ πpid (P arts)
Tuple Relational Calculus (TRC):
{S.sid | Suppliers(S) ∧ ∀P (P arts(P ) ∧ P.color =′ red′ → ∃C(Catalog(C) ∧ C.sid = S.sid ∧ C.pid = P.pid))}
2.
πsname (πsid (σcolor=′ red′ (P arts)) ▷◁ (σcost<100 (Catalog)) ▷◁ Suppliers)
This Relational Algebra statement returns no results due to the order of the projection operations. After
projecting sid, it becomes the only remaining field in the result set. Consequently, attempting to project
sname afterward will yield nothing, as sname is no longer available.
3.
This query returns the names of suppliers who supply both red and green parts, with the condition that the
cost of both types of parts is less than 100 units.
4.
This query finds the sid ’s of suppliers who supply both red and green parts with a cost of less than 100
units.
2
5.
This query retrieves the names of suppliers who supply both red and green parts with a cost of less than 100
units.