in Databases
412 views
1 vote
1 vote

Given,

Suppliers(sid,sname,rating)

Parts(pid,pname,color)

Catalog(sid,pid,cost)

1.Retrieve sid of the suppliers who supplied some red or some green part.

I did it this way-  {t | ∃c∊Catalog ∃p∊ Parts(c.pid=p.pid ∧ p.color="Red" ∨ p.color="Green" ∧ t.sid=c.sid)}

1 more way to do-- {t | ∃c∊Catalog (∃p∊ Parts( p.color="Red" ∨ p.color="Green"∧ c.pid=p.pid) ∧ t.sid=c.sid)}

I want to verify whether these TRC  queries are correct or not.Also correct me if i am wrong.

Suggest some other ways if possible.

 Also,

2. Retrieve sid of suppliers who supplied at least two parts.

in Databases
by
412 views

1 Answer

2 votes
2 votes

1.{t.sid |∃t∊Supplier, ∃c∊Catalog ,∃p∊ Parts( p.color="Red" ∨ p.color="Green" ∧c.pid=p.pid ^t.sid=c.sid)}

2.{t.sid |∃t∊Supplier, ∃c∊Catalog,∃p1,p2∊ Parts( p1.pid != p2.pid ∧c.pid=p.pid^ t.sid=c.sid)}

Related questions