Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help creating the following queries in MYSQL 2. In this problem, you will design a relational schema for an online food delivery system

I need help creating the following queries in MYSQL

2. In this problem, you will design a relational schema for an online food delivery system similar to DoorDash. This service allows people to order food online, and then delivery people will deliver orders to customers. When customers are waiting for their food, they are able to check the status of their order. Customers can leave a review for an order that includes a separate rating of each food item in the delivery, a rating for the delivery itself, as well as optional comments. Each order only includes food from a single restaurant, but the order may include several food items from that restaurant. Different restaurants may have dishes with the same name, but these dishes will often have different descriptions and differ in information such as calories and serving size. Customers may receive coupons from restaurants. Each such coupon is for a fixed amount (e.g., $1.50 off), can only be used at the restaurant that issued it, and only by the customer that received it. Coupons are automatically applied to any future order at that restaurant, but have an expiration date. To simplify the design, we do not model the case of the same restaurant having several locations. Ratings for food items and for delivery are on a scale from 1 to 5. For this homework, you need to design a suitable relational schema for this scenario. Thus, you need to store information about customers (e.g., name, age, email, credit card, phone number), restaurants (e.g., name, zip code, category (e.g., Chinese, Seafood, Korean, or Italian)), food items (e.g., food name, description, price), the people doing the delivery (name, phone number), orders, and coupons. (a) Design a relational database schema for this online application that supports all the functionality. You should state reasonable assumptions about your schema that you find necessary. You need to specify the primary keys and foreign keys for each table. (b) Write SQL statements for the following queries. I. Output the name of all delivery people who delivered an order that received five stars for delivery but only one star for at least one of the food items delivered in the order. II. For each restaurant, output the name of the food item(s) with the highest average rating score given by customers. III. For each restaurant, output the name of the customer(s) with the largest number of unexpired coupons. IV. Output the number of customers who ordered hamburger but did not order fries in the same order.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions