The Databases Course
Exercise No. 4
Relational Algebra, Calculus and QBE
Due on December 16th by midnight
This is a very important exercise - it summarizes the subject of query languages. However, it is slightly bigger than the other exercises. To encourage you to do it anyway, anyone who submits this exercise will get an automatic bonus of two points. So the maximum grade is 22 out of 20!
- Find the drinkers that frequent only bars that serve some beer that they like.
- Find the drinkers that frequent no bar that serves a beer that they like.
1
, ..., Rn
) over a given database. For all i=1..n Ri
has ti
tupples and si
attributes. The result of the query is a
relation with tq
tupples and sq
attributes. Q may be any well defined query in
relational algebra, and we assume that all atomic values
appearing in the output must also appear in the input (no
calculated fields, etc.). We also assume that Q contains
exactly q
operators.
- Show an upper bound for the number of tuples that can belong to the answer of Q.
- Show that this bound can be achieved using the relational algebra (or calculus).
- Is there such a bound in the SQL Model, where a table may contain duplicate rows?