Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



Consider the relational schema of sailors $S$, Reserves $R$ and Boats $B$.Table 1: Sailors $S$
SidSnameRatingAge
22Dustin745.0
29Brutus133.0
31Lubber855.5
32Andy825.5
58Rusty1035.5
64Horatio735.5
71Zorba1016.0
74Horatio935.0
85Art325.5
95Bob363.5
Table 2: Reserves $R$
SidBidday
2210110/10/98
2210210/10/98
2210310/8/98
2210410/7/98
3110211/10/98
3110311/6/98
3110411/12/98
641019/5/98
641029/8/98
741039/8/98
Table 3: Boats $B$
BidBnameColor
101Interlakeblue
102Interlakered
103Clippergreen
104Marinered
Which of the following relational algebra query computes the names of sailor who have reserved all boats?





Solution

We need the names of sailors who have reserved all boats.

In relational algebra, when we need to find entities related to all values of another relation, we use division operation.

Here,

$Reserves(Sid,Bid,day)$ tells which sailor reserved which boat.

$Boats(Bid,Bname,Color)$ tells all available boats.

First, take only required columns from Reserves:

$\pi_{sid,bid}(Reserves)$

This gives pairs of sailors and boats reserved by them.

Now take all boat IDs from Boats:

$\pi_{bid}(Boats)$

To find sailors who reserved every boat, apply division:

$(\pi_{sid,bid}(Reserves))/(\pi_{bid}(Boats))$

This gives only those $sid$ values which are associated with all $bid$ values.

Now rename this result as $Tempsids$:

$\rho(Tempsids,((\pi_{sid,bid}Reserves)/(\pi_{bid}Boats)))$

Finally, join $Tempsids$ with Sailors table to get sailor names:

$\pi_{sname}((Tempsids)\bowtie Sailors)$

So, the correct query must use:

$\pi_{sid,bid}Reserves$

and

$\pi_{bid}Boats$

with division operation.

Option (b) correctly represents this logic.


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...