Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

Lab Assignment 5

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lab Assignment 5

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Assigment-5

• When writing a relational algebra it would work over all possible database instances and not
just for the given example instance!

Consider the following database schema and example instance:

ingredient
recipe
recipe foodItem ounces
name inventor kitchen Pasta and Meatballs Pasta 50
Pasta and Meatballs Le cook Italian Pasta and Meatballs Meatballs 10
Cheese Soup The french French Pasta and Meatballs Tomato Sauce 5
Burger Cowboys American
Pasta and Meatballs Onions 1
Cheese Soup Onions 4
Cheese Soup Cheese 15
foodItem Cheese Soup Bread 20
Burger Bread 10
item type calorie Burger Ground Beef 20
s
Pasta Wheat 20
product stock
Meatballs Meat 40
Tomato Sauce Sauce 5 foodIte shop price
Onions Vegetables 1 m
Cheese Diary 30 Pasta Aldi 5
Bread Wheat 25 Meatballs Aldi 10
product Tomato Aldi 3
Ground Beef Meat 45 Sauce
Tomato Walmart 3
Sauce
Hints:
Cheese Treasury 15
Island

• Underlined attribute form the primary key of a relation


• The attribute recipe of relation ingredient is a foreign key to relation recipe. The attribute
foodItem of relation ingredient is a foreign key to relation foodItem.
• The attribute foodItem of relation stock is a foreign key to relation foodItem.
Question 1
Write a relational algebra expression that returns the food items required to cook the recipe “Pasta
and Meat- balls”. For each such food item return the item paired with the number of ounces required
by the recipe.

Question 2
Write a relational algebra expression that returns food items that are sold at “Aldi” and their price.

Question 3
Write a relational algebra expression that returns food items (item) that are of type “Wheat product”
or of type “Meat” and have at least 20 calories per ounce (attribute calories).

Question 4
Write a relational algebra expression that returns the items and their price for all items of type “Wheat
product” sold at Aldi.

Question 5
Write a relational algebra expression that returns the names of all recipes that contain meat products
(food items of type “Meat”).

Question 6
Write a relational algebra expression that returns all recipes that contain both “Onions” and
“Cheese”.

Question 7
Write a relational algebra expression that returns the food items that are ingredients for “Cheese
Soup” but not for “Burgers”.

Question 8
Write a relational algebra expression that returns the total number of ounces for all ingredients per
recipe.

Question 9
Write a relational algebra expression that returns the average price of food items per type. For
example, this expression should return tuples like (Wheat product, 34.5).

Question 10
Write a relational algebra expression that returns the number of food item types for which the average
calories for all food items of this type is higher than 40.

You might also like