edited by
1,136 views
3 votes
3 votes

BOOK(ACC_NO, TITLE, YR_PUB)

USER(CARD_NO, B_NAME, B_ADD)

B_BY(ACC_NO , CARD_NO , DOI)

SUPPLIER(S_NAME,S_ADD)

S_BY(S_NAME,S_NAME,PRICE,,DOS)

Query :- find the names of those supplier who have supplied titles corresponding to all book issused by 'VIJAY'.

using relational calculus solve the query (if possible give proper explation) 

edited by

1 Answer

3 votes
3 votes

This query is quite simple in terms that its very logical... let's see this step wise

Step 1: B_name =" Vijay" present in User relation having Card_no. as the key

Step 2: Card_no is an attribute of B_by relation having Acc_no as an attribute which will be referencing to the Book relation

Step 3: Book relation contains Title which will give titles for a particular Acc_no....we have to find Acc_no of such other similar Titles too...

Step 4: after we successfully found out the possible Acc_no of "Titles" issued by Vijay we join S_by and Book relations to find and display the S_name for the projected Acc_no.

hence the query becomes :

z = { t | ∀ a ∈ User ( a [B_name] = "VIJAY" ==>                 /* selecting tuples with B_name = "VIJAY"*/

        ∃ b ∈ B_by( a[Card_no] = b[Card_no] ∧            /* natural join of B_by(b) and User(a) for Card_no of "Vijay"*/

        ∃ c ∈ Book( c[Acc_no] = b[Acc_no])  ∧    /* natural join of Book(c) and B_by(b) for Acc_no of books issued to the Card_no of "VIJAY" */

         ∃ d ∈ Book( c[Title] = d[Title]) ∧          /* cartesian product of Book(c) with Book(d) to find Titles same as Titles issued by "VIJAY"*/

         ∃ e ∈ S_by( d[Acc_no] = e[Acc_no] ∧ t[S_name] = e[S_name] )  /* natural join of S_by(e) and relation d to find S_name for the all Titles issued by Vijay*/

         )

      )

  }

   I hope this is the correct solution. Still, any suggestion is Welcome. I face issues with brackets. Any help regarding that.

Related questions

0 votes
0 votes
1 answer
1
1 votes
1 votes
2 answers
4
tarunmaganti asked Apr 15, 2018
776 views
If there are three tables to choose from -Sailors(sid,sname); Reserves(sid,bid); Boats(bid,color)Question is to choose a sailor who reserved a red boat.My question is wha...