Relational Algebra:
Consider the following restaurant database. You are to use the
following relational database schema, where primary keys are
indicated by being underlined.
Customers place orders for food items. Hence, there are
relations (entity sets) for FoodItem, Customer, and Order. A
customer can have placed many orders, but an order is associated
with only one customer. This is captured by the PlaceOrder
relation, which is a relationship in the ER model. One order is
composed of some number of food items, where there may be multiple
quantities of the same item. This is captured by the PartOfOrder
relation, which is a relationship in the ER model.
(Side note: If a group of people want to order food together and
have one customer pay, the order is associated with the paying
customer. If people want to split checks, each order becomes its
own order.)
Each of the attributes is explained as follows:
FoodItem.itemID: The primary key of the relation
FoodItem.name: The name of the item, for example, “cheeseburger”
or “small fries”
FoodItem.calories: The number of calories in one serving of that
food item
FoodItem.price: The cost of the item (Assume it is represented
as float number, which is the price in dollars, for example, 2.50
is $2.50.)
Order.orderID: The primary key of the relation
Order.oDate: The date the order was made
Customer.custID: The primary key of the relation
Customer.name: The name of the customer
Customer.creditCardNum: The customer’s credit card number
(assume just one card)
Customer.bdate: The customer’s birthdate
PartOfOrder.custID: The customer ID for the person placing the
order
PartOfOrder.itemID: The food item ID
PartOfOrder.quantity: How many of that item are in the order,
for example, 2 small fries
PlacedOrder.orderID: The orderID
PlacedOrder.custID: The ID of the customer who placed the
order
In the following questions, you are asked to provide relational
algebra queries. You may not use Cartesian
products (use equi or natural joins).
Answer using RELATIONAL ALGEBRA.
A)What is the name of all food items that have fewer than 600
calories and cost less than 2.50?
B)What is the order ID for orders made on 2019-02-14 that
included two or items called “tuna roll”?
C) Find the name of customers who have ordered one or more
of each and every food item.
Foodltem itemID, name, calories, price Order orderID, Date Customer custID, name, creditCardNum, bdate PartOfOrder orderID, itemID, quantity PlacedOrder orderlD, custID
Relational Algebra: Consider the following restaurant database. You are to use the following relational database schema,
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Relational Algebra: Consider the following restaurant database. You are to use the following relational database schema,
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!