[CLO1] In this assignment, you are to write relational algebra queries over a small sample database. It contains four re
-
- Site Admin
- Posts: 899566
- Joined: Mon Aug 02, 2021 8:13 am
[CLO1] In this assignment, you are to write relational algebra queries over a small sample database. It contains four re
[CLO1] In this assignment, you are to write relational algebra queries over a small sample database. It contains four relations: Person(name, age, gender) Visits(name, restaurant) Eats (name, pizza) Serves (restaurant, pizza, price) // name is a key // [name, restaurant] is a key // [name, pizza] is a key 1/ [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
• Person Person.Name Person.age Person.gender 'Amna' 16 'female' "Bilal' 21 'male' 'Chishti' 33 'male' "Danish 13 'male' 'Ehsan' 45 'male' 'Faria' 21 'female' 'Gauhar' 24 'male' "Hamna' 30 'female' 'Irfan' 18 'male' • Visits Visits.name Visits.restaurant 'Amna' 'Pizza_Hut' 'Bilal' 'Pizza Hut' 'Bilal' 'Tehzeeb' 'Chishti' 'Pappasallis' 'Chishti' 'Rahat "Danish' 'Pappasallis' 'Danish' "Rahat' 'Ehsan' "Rahat' 'Ehsan' 'Faria' 'Faria' 'Tehzeeb' 'Dominos' 'Italian_Oven'
'Gauhar' 'Gauhar' 'Hamna' "Hamna' 'Pizza_Hut' 'Tehzeeb' 'Dominos' 'Pizza Hut' "Rahat' 'Dominos' 'Pappasallis' "Rahat' "Hamna' 'Irfan' 'Irfan' 'Irfan' • Eats Eats.name Eats.pizza 'Amna' 'fajita' 'Amna' 'mushroom' 'Bilal' 'cheese' 'Bilal' 'fajita 'Chishti' 'chicken_tikka' 'Danish' 'cheese' 'Danish' 'chicken_tikka' 'Danish' 'fajita' "Danish' 'mushroom' 'Danish' 'sausage' 'Ehsan' 'cheese' "Ehsan' 'chicken_tikka' 'Faria' 'mushroom' 'Gauhar' 'cheese' 'Gauhar' 'chicken_tikka'
'Gauhar' "Hamna' "Hamna' 'mushroom' 'cheese' 'chicken_tikka' 'chicken_tikka' 'fajita' 'Irfan' 'Irfan' • Serves Serves.restaurant Serves.pizza Serves.price 'Dominos' 'cheese' 975 'Dominos' 'mushroom 1100 'Italian_Oven' 'cheese' 700 'Italian_Oven' 'fajita' 975 'Italian_Oven' 'mushroom' 925 'Italian_Oven' 'sausage' 950 'Pappasallis 'cheese' 700 'Pappasallis' 'chicken_tikka'850 'Pappasallis 'fajita' 800 'Pizza Hut 'cheese' 900 'Pizza Hut' 'chicken_tikka'1200 'Pizza Hut 'fajita 1200 'Pizza Hut' 'sausage' 1200 'Rahat' 'cheese' 925 "Rahat 'fajita' 800 'Rahat 'sausage' 975 'Tehzeeb' 'cheese' 775 'Tehzeeb 'chicken_tikka'850