Question: Over a relation Borrow ( reader , book,date ) , consider the following SQL expression: with B as ( select book, count ( * )
Over a relation Borrowreaderbook,date consider the following SQL expression:
with B as
select book, count as number
from Borrow
group by book
select
from B natural join
select maxnumber as number from B
Which statements are correct? In relational algebra we use project to indicate projections and sigma to indicate selections.
The same query can be equivalently written in SQL as follows:
with Maxbook as
select book, maxdate as number
from Borrow
group by book, reader
select book, number
from Borrow natural join Maxbook
The following SQL expression is NOT equivalent:
select book, maxnumber
from select book, count as number
from Borrow
group by book
group by book
This expression returns, for each book, the maximum number of readers who borrowed it
This expression returns the book or books that has been borrowed by the largest number of different readers.
This expression returns the book or books that has been borrowed the most often, together with the number of times it was borrowed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
