in Databases edited by
1,665 views
0 votes
0 votes
Caption

Can plz any one give solutions of e,f,g,h in relational algebra?

 

in Databases edited by
1.7k views

4 Comments

yes @Shaik I understood it need division operation

but here we need to join 3 tables Supplier, Parts and Catalog

right?

plz tel me why u havenot done that?
0
0
mam,there is no need of suppliers table information
1
1
ok , yes u r right :)
0
0

1 Answer

3 votes
3 votes
Best answer

Suppliers(Sid,Sname,rating) ------> (sid) is key

Parts(Pid,Pname,color) ------> (pid) is key

Catalog(sid,pid,cost) ------> (sid,pid) is key

 

1) Retrieve sid's supplied only RED parts

         it means the suppliers didn't supply atleast one non-red parts ===> ( total red suppliers ) - ( total non-red suppliers )

    πsid ( Catalog  ⊠ catalog.pid = Parts.pid   ( σcolor = 'red' ( Parts ) )  )  -  πsid ( Catalog  ⊠ catalog.pid = Parts.pid   ( σcolor ≠ 'red' ( Parts ) )  )

 

2) Retrieve sid's supplied EVERY RED part

     it means sid's who supplied every RED parts ===> when EVERY ( ALL ) term encounter, use DIVISION operator in RA

    πCatalog.sid,P.color ( Catalog  ⊠ Catalog.pid = Parts.pid  ( Parts ) )  ) /   πParts.pid (  ( σcolor = 'red' ( Parts ) )  )

 

3) Retrieve sid's supplied EVERY RED part or EVERY green part

     Union the RED and Green 

   ( πCatalog.sid,P.color ( Catalog  ⊠ Catalog.pid = Parts.pid  ( Parts ) )  )  /  πParts.pid (  ( σcolor = 'red' ( Parts ) )  ) )

πCatalog.sid,P.color ( Catalog  ⊠ Catalog.pid = Parts.pid  ( Parts ) )  )  /  πParts.pid (  ( σcolor = 'green' ( Parts ) )  ) )

 

4) Retrieve sid's supplied EVERY RED part but not ANY GREEN part

     Set difference of All RED and ANY Green 

   (  πCatalog.sid,P.color ( Catalog  ⊠ Catalog.pid = Parts.pid  ( Parts ) )  )  /  πParts.pid (  ( σcolor = 'red' ( Parts ) )  ) )

-

πCatalog.sid ( Catalog  ⊠ Catalog.pid = Parts.pid ( σcolor = 'green' ( Parts ) )  ) )

 

selected by

4 Comments

2nd comment is for number h) i.e. 4th one

chk u missed p.color=red

and u havenot directly join with Catalog with Parts

just minor update I have done :)

0
0

for 1st one... Yes, that didn't make any difference... Your query also right...

for 4th one...

i use p.color="red" at division query

your query also correct but there is a minor mistake in that

used p.colour="red" used with projection operator but it should be with selection operator

1
1
yes rt
0
0

Related questions