Question

3. The database contains the following relations: (18 pts)

Person (ID, name, age, gender) // ID is a key

(e.g.. (1, Gary, 30, M), (2, Mary, 21, F)...)

Shop_list (ID, item) // (ID, item) is the key

(e.g.. (1, 1), (1, 2), (2, 2), (2,3)...)

Sell (supermarket, item, price) // (supermarket, item) is the key

(e.g.. (Walmart, 1, 3.0), (Walmart, 2, 2.50). (Costco, 3, 50.0), (Costco, 1, 2.50)...)

Write relational algebra expressions to answer the following queries, using Project

operation to project the result tuples onto only the column(s)/attribute(s) requested.

Assume all relational operators take their (default) set semantics.

a. Find all the items on the shop_list of at least one person over the age of 18. (5pts)

b. Find the names of all males who have at least one item in their shop_list sold at

Walmart. (6 pts)

c.

Find for each person, the lowest price of items on his/her shop_list. (Hint: Gamma

operation) (7 pts)

Question image 1