You are on page 1of 3

COMSATS UNIVERSITY, ISLAMABAD

Department of Computer Science


Lab Assignment - 1, Spring - 2022

Course: Database Systems - I (CSC371) Class: BCS IV


Instructor: Qasim Malik Total Marks: 25

[CLO1] In this assignment, you are to write relational algebra queries over a small sample database. It contains
four relations:

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


Visits(name, restaurant) // [name,restaurant] is a key
Eats(name, pizza) // [name,pizza] is a key
Serves(restaurant, pizza, price) // [restaurant,pizza] is a key

I have also added few tuples in each of the relations. You can view them in Database.xlsx file. You are to write
relational algebra expressions over the database for the following 9 queries. I have also provided the results
for each of the query. You need to figure out the query in relational algebra that must produce the same result.

To verify if your query would produce the same result, I recommend you to execute it using web-based RA
calculator – RelaX (https://dbis-uibk.github.io/relax/landing). For each of the following queries, write down the
expressions using standard RA notations along with the corresponding expression tree representation and the
number of rows returned in results.

1 - Find all pizzas eaten by at least one female over the age of 19. [1.5 marks]

Expected Query Result:

cheese

chicken tikka

Mushroom

2 - Find the names of all females who eat at least one pizza served by Rahat. (Note: The pizza need not be
eaten at Rahat.) [1.5 marks]

Expected Query Result:

Amna

Hamna

3 - Find all restaurants that serve at least one pizza for less than Rs.1000 that either Amna or Faria (or both)
eat. [1.5 marks]

Expected Query Result:

Italian Oven

Pappasallis

Rahat
4 - Find all restaurants that serve at least one pizza for less than Rs.1000 that both Amna and Faria eat. [1.5
marks]

Expected Query Result:

Italian Oven

5 - Find the names of all people who eat at least one pizza served by Dominos but who do not visit Dominos.
[1.5 marks]

Expected Query Result:

Amna

Bilal

Danish

Ehsan

Gauhar

6 - Find all pizzas that are eaten only by people younger than 24, OR that cost less than Rs.1000 everywhere
they are served. [2.5 marks]

Expected Query Result:

cheese

fajita

sausage

7 - Find the age of the oldest person who eat mushroom pizza. [5 marks]

Expected Query Result:

24

8 - Find all restaurants that serve ONLY pizzas eaten by people over 30. [5 marks]

Expected Query Result:

Tehzeeb

9 - Find all restaurants that serve EVERY pizza eaten by people over 30. [5 marks]

Expected Query Result:

Pappasallis

Pizza Hut

Tehzeeb

You might also like