Questions 1

Consider the example schema for bars to answer the following questions.

Hint

$\sigma$ is the selection operator. Selecting in relational algebra is used to show only a selection of rows. $\pi$ is the projection operator. It is used to pick out columns which you want to show. The $\times$ operator is used to build the cartesian product of two relations. This is accomplished by pairing every row of the first relation with every row of the second relation.

Question 1

a) $\sigma_{price\leq2.00}(Sells)$
b) $\sigma_{bar=\"Sue's\"}(Bars)$
c) $\pi_{beer,price}(Sells)$
d) $\pi_{adress}(Bars)$
e) $Bars \times Sells$

Answer

a)

Question 2

a) $\pi_{beer}(\sigma_{price\geq5.00}(Sells))$
b) $\sigma_{bar="Moe's"\wedge~price<2.50}(Sells)$
c) $\sigma_{address="River~Rd."\vee~address="Maple~St."}(Bars)$
d) $\pi_{bar}(\sigma_{beer="Stout"}(Sells))$