Question

*Part II:Smith has decided to track customers and what s/he is orderingthe most. In order to...

*Part II:Smith has decided to track customers and what s/he is orderingthe most. In order to do this,create a fifth base entitytothe database (i.e., table)called OrderNumber. For this table, Smith wants to be able to have a unique order number(each time the customer visitsthe restaurant), the customer number, and what food the customer ordered(assume the customer only orders one itemeach visit).As the database administrator,Smith is allowing you to setup the table, relationship(s), and ensure that at least 10 records are entered. Avoid using the same customer for each all 10 records.Smith would like the database administrator to create 3queries based on the following criteria:
•Determine that most popular food item orderedby all customers. (Display the food name and number of items it was ordered—sort the food name in ascendingorder).
•Which customer visited the restaurantthe most. (Display the customer’s name, address, phone and email address).
•Smith would like you to include one query that uses the average function. You get to elect how this query is implemented but ensure that the OrderNumber table is used.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer..-

Step 1 : Create a table OrderNumber which has 3 columns ('OrderNo' 'CustomerNo' 'Food Name')

create table OrderNumber('OrderNo' INT NOT NULL PRIMARY KEY,

'CustomerNo' INT,

'Food Name' VARCHAR(25));

Step 2 : Create Another table Having Information about every customer.

create table Customer('CustomerNo' INT,

'Name' VARCHAR(25),

'Address' VARCHAR(25),

'PhoneNo' INT(10),

'E-mail ID' VARCHAR(50));

Step 3 : Enter Details in Table OrderNumber .

For Ex. , INSERT INTO OrderNumber VALUES(1,1,'Masala Dosa');

INSERT INTO OrderNumber VALUES(2,2,'Idli');

Step 4 : Enter Details in Table Customer.

For Ex. , INSERT INTO Customer VALUES(1,'Rajesh','Delhi', 1234567890,'[email protected]' );

INSERT INTO Customer VALUES(2,'Mahesh','Amritsar', 9876541230,'[email protected]' );

Step 5 : Enter the Details of all the customers as above

QUERY 1 : Determine that most popular food item ordered by all customers. (Display the food name and number of items it was ordered—sort the food name in ascending order).

ANSWER: SELECT Food_Name,COUNT(*)

FROM OrderNumber

GROUP BY Food_Name

ORDER BY Food_Name ASC;

QUERY 2 : Which customer visited the restaurant the most. (Display the customer’s name, address, phone and email address).

ANSWER: SELECT *

FROM Customer

WHERE CustomerNo IN (SELECT DISTINCT CustomerNo

FROM OrderNumber

GROUP BY CustomerNo

ORDER BY Count(*)

DESC LIMIT 1);

QUERY 3: Smith would like you to include one query that uses the average function. You get to elect how this query is implemented but ensure that the OrderNumber table is used.

ANSWER: As OrderNumber Table does not contain a column for which calculation of average makes any sense but for only to show how Average(AVG) function is used in database I have calculated the average of OrderNo (which does not any sense). So the Query is as follows -

SELECT AVG(CustomerNo) FROM OrderNumber;

Add a comment
Know the answer?
Add Answer to:
*Part II:Smith has decided to track customers and what s/he is orderingthe most. In order to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need to create a SQL query that displays the names of the customers who purchased...

    I need to create a SQL query that displays the names of the customers who purchased the book with the highest retail price in the database. Also I need to capitalize the first and last names. CUSTOMERS Table: CUSTOMER#, LASTNAME, FIRSTNAME, ADDRESS, CITY, STATE, ZIP, REFERRED, REGION, EMAIL ORDERS Table: ORDER#, CUSTOMER#, ORDERDATE, SHIPDATE, SHIPSTREET, SHIPCITY, SHIPSTATE, SHIPZIP, SHIPCOST ORDERITEMS Table: ORDER#, ITEM#, ISBN, QUANTITY, PAIDEACH

  • Write a SQL query that shows the price of each order made by customers whose last name starts wit...

    Write a SQL query that shows the price of each order made by customers whose last name starts with the letter M. Display the order number, the last name on the order, and the price of the order (Order Price). Show the results with the highest order price first. Write a SQL query that determines the most expensive item purchased in each order (Item Price). Display the order number, the date of the order, the last name of the customer...

  • The Case Express Delivery (ED) is a Morgantown based home goods company. Customers can call in...

    The Case Express Delivery (ED) is a Morgantown based home goods company. Customers can call in orders and ED mails the items to the customer. They also email the customers a bill, as seen below. Customers can mail in a check, once they receive the order. ED needs to track whether the order has been paid or not, but the payment information is handled by a third-party vendor. ED needs to create a database to track their customers. Each customer...

  • a) Determine the order-ID and the total price of each order.(Note that the total price of...

    a) Determine the order-ID and the total price of each order.(Note that the total price of an order is the price for the ordered products on the day of the order plus the price of the selected shipping.) Note. The requested query is quite complicated(and long). The main problem is that you have to determine the price of the ordered products at the day of the order. Recall that the price table stores the price of a product starting at...

  • Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...

    Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...

  • Problem 33, chapter 7 from Database Systems 13th edition by Coronel Write a query to display...

    Problem 33, chapter 7 from Database Systems 13th edition by Coronel Write a query to display the employee number, last name, email address, title, and department name of each employee whose job title ends in the word “ASSOCIATE.” Sort the output by department name and employee title Problem 36, chapter 7 from Database Systems 13th edition by Coronel Write a query to display the number of products within each base and type combination, sorted by base and then by type...

  • SQL Queries – in this assignment you will be asked to create several SQL queries relating...

    SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...

  • Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary...

    Exercise 3 [12.5 marks] Given the Restaurant management system database that contains the following tables (primary keys are underlined and foreign keys are preceded with #): Customer (customerID,customerFirstName,customerLastName,customerAddress) Oreder (orderID,orderDate, #customerID,#menuItemID,#staffID) MenuItem(menuItemID, menuItemName,ingredients,type,availability) Staff(staffID, staffName, staffPhoneNumber, staffRole ) OrderPayment(paymentID,paymentAmount,#orderID,#staffID) 1) Without using DISTINCT, write the SQL query equivalent to the following one:[1.5 marks] SELECT DISTINCT menuItemName FROM MenuItem WHERE type = ‘Vegetarian’ OR availability= ‘Yes’; 2) Express the following queries in SQL: a) Find the number of orders placed by...

  • You will develop an E-Commerce database used to maintain customers, products and sales information. You are...

    You will develop an E-Commerce database used to maintain customers, products and sales information. You are required to 1) gather and analyze requirements 2) design logical structure of the database 3) create stored procedures to develop the tables and insert the data 4) write SQL statements for data extraction and reporting. Throughout the course of this semester you have analyzed the requirements for an eCommerce database, designed and developed your database. As a class we have gone through the process...

  • Arrays Artistic Solutions wants to keep track of 100 of customers, including the following fields: Customer...

    Arrays Artistic Solutions wants to keep track of 100 of customers, including the following fields: Customer ID Last Name First Name Street Address City State Zip Code Phone Number Email Address Without access to a database program, you decide that keeping this information in one or more arrays is the best solution. The question is, what kind or kinds of arrays would you use? Discuss whether any or all of the following is suitable for this application, indicating why you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT