0% found this document useful (0 votes)
40 views

Comsats University, Islamabad Department of Computer Science

1. This lab assignment asks students to write relational algebra queries over a sample database with four relations: Person, Visits, Eats, and Serves. Students must write queries and expression trees for 9 queries and return the expected result. 2. The sample database contains information about people (name, age, gender), what restaurants they visit, what pizzas they eat, and what pizzas are served at each restaurant along with price. 3. Students are instructed to use the RelaX online relational algebra calculator to test their queries and expression trees and return the number of rows in the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Comsats University, Islamabad Department of Computer Science

1. This lab assignment asks students to write relational algebra queries over a sample database with four relations: Person, Visits, Eats, and Serves. Students must write queries and expression trees for 9 queries and return the expected result. 2. The sample database contains information about people (name, age, gender), what restaurants they visit, what pizzas they eat, and what pizzas are served at each restaurant along with price. 3. Students are instructed to use the RelaX online relational algebra calculator to test their queries and expression trees and return the number of rows in the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

COMSATS UNIVERSITY, ISLAMABAD

Department of Computer Science


Lab Assignment - 1, Spring - 2022

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


Instructor: Dr. Basit Raza 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