Question

There are five categories of data to be stored in the database: Ingredients Ingredient Name Amount in Stock Menu Items Menu I
3. (30 points) Based on the relational model you provided as your answer to question no. 2, write SQL queries for the followi
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Short Summary:

  • Have created the given tables and formed the sql queries as per the requirement

**************Please do upvote to appreciate our time. Thank you!******************

Solution:

1. Query 1:

select menuItemName from MenuItems where Ingredients not in (select IngredientsAllergicTo from Customer where customerID=100)

2. Query 2:

select menuItemName from MenuItems where saleprice is not null and saleprice < regularPrice

3. Query 3:

select sum(priceSoldAt) As 'Revenue' from salesData
where MenuItemsSold in (select menuID from MenuItems where menuItemName='Fish Fry')
group by MenuItemsSold

Detailed Queries and output:

CREATE TABLES:

CREATE DATABASE MenuIT
USE MenuIT
CREATE TABLE Employees(
SSN INT PRIMARY KEY,
employeeName VARCHAR(20),
employeeAddress VARCHAR(100),
HourlyWage INT
)


CREATE TABLE Customer (
CustomerID INT PRIMARY KEY,
CustomerName varchar(255),
CustomerAddress varchar(255),
IngredientsAllergicTo varchar(255)
);

CREATE TABLE MenuItems (
menuID INT PRIMARY KEY,
menuItemName varchar(255),
Ingredients varchar(255),
regularPrice decimal(18,2),
saleprice decimal(18,2)
);

CREATE TABLE SalesData (
transactionDate DATETIME,
ServerID INT,
customerID decimal(18,2),
MenuItemsSold INT,
priceSoldAt decimal(18,2),
FOREIGN KEY(ServerID) REFERENCES Employees(SSN),
FOREIGN KEY(MenuItemsSold) REFERENCES MenuItems(menuID),
);

Test Data:

INSERT INTO MenuItems VALUES (1, 'Mushroom Pepper Fry', 'Mushroom', 10, 5)
INSERT INTO MenuItems VALUES (2, 'Avacado Sandwich', 'Avacado', 13.50, 17.50)
INSERT INTO MenuItems VALUES (3, 'Fish Fry', 'Fish', 20.50, 15.50)

INSERT INTO Customer VALUES(100, 'Kevin peter', 'Atlanta, GA', 'Avacado')
INSERT INTO Employees VALUES(123456789, 'Mai', 'Dunwoody, GA', 14.50)

INSERT INTO SalesData VALUES(GETDATE(), 123456789, 100, 3, 15)
INSERT INTO SalesData VALUES(GETDATE(), 123456789, 100, 2, 10)
INSERT INTO SalesData VALUES(GETDATE(), 123456789, 100, 3, 15)

Query 1:

-- For customer with id = 100
select menuItemName from MenuItems where Ingredients not in (select IngredientsAllergicTo from Customer where customerID=100)

image.png

Query 2:

image.png

Query 3:
select sum(priceSoldAt) As 'Revenue' from salesData
where MenuItemsSold in (select menuID from MenuItems where menuItemName='Fish Fry')
group by MenuItemsSold

image.png

**************Please do upvote to appreciate our time. Thank you!******************

Add a comment
Know the answer?
Add Answer to:
There are five categories of data to be stored in the database: Ingredients Ingredient Name Amount...
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
  • This is third time im posting this Question COURSE; introduction to database Please, No handwriti...

    This is third time im posting this Question COURSE; introduction to database Please, No handwriting thanks for your efforts Design the database by following . Execute the sample requested queries. . ER Diagram. . All schemas before and after normalization. . All SQL statements of: -Creating tables. - Inserting data in tables. -Queries. 5. Screenshots from MySQL (or any other software you use) Question is - Database system for a Wholesale Management System Consider a database system for a Wholesale...

  • This is third time im posting this Question COURSE; introduction to database Please, No handwriting thanks...

    This is third time im posting this Question COURSE; introduction to database Please, No handwriting thanks for your efforts Design the database by following . Execute the sample requested queries. . ER Diagram. . All schemas before and after normalization. . All SQL statements of: -Creating tables. - Inserting data in tables. -Queries. 5. Screenshots from MySQL (or any other software you use) Question is - Database system for a Wholesale Management System Consider a database system for a Wholesale...

  • Please help me to solve Please, No handwriting COURSE; introduction to database Q- write a query ...

    Please help me to solve Please, No handwriting COURSE; introduction to database Q- write a query SQL by Using the info below A. Normalize the Tables (in 3NF at least) B. Create the Normalized Tables and Populate them with at least 5 Rows C. Write the Wholesale Management System requested Queries & Execute them VERY IMPORTANT Screenshots from MySQL (or any other software you use) of all the tables after queries result. - Database system for a Wholesale Management System...

  • 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...

  • Database Exercise I (50 pts): This exercise deals with a database that stores information about Hotel...

    Database Exercise I (50 pts): This exercise deals with a database that stores information about Hotel Management System. Customer (C email, name, country) Payment (Invoice id, C email, payment method, date) invoice (Invoice id, starus, invoice description) Has (Bill id. Invoice id) 9a Bill (Invoice id, Bill id, amount, Bname, type, date, reservation id) Reservation (Hotel id, room id, C email, date, period, reservation id) Rooms(Hotel id. room id, price, category) Hotel (Hotel id. H name. country) Own (room id,...

  • USING SQL TO RETRIEVE DATA FROM DATABASE AND GENERATE REPORTS BASED ON REQUIREMENTS. This is using...

    USING SQL TO RETRIEVE DATA FROM DATABASE AND GENERATE REPORTS BASED ON REQUIREMENTS. This is using SQL Server Management Studio (SSMS). Task: Important: Use one and only one SQL Statement to get results for each of the following items. Query #                                                                Description 1. List the ID and name of the product(s) that didn’t get ordered by any customer. Use a subquery Here is an example of the database schema: Here are the tables created: ESELECT TOP (1000) [CustomerID] [CustomerNamel [Street]...

  • Create the following SQL Server queries that access the Northwind database Same as problem 3 but,...

    Create the following SQL Server queries that access the Northwind database Same as problem 3 but, limit the list to all customers who placed 3 or more orders. The product id, product name, last date that the product was ordered for all items in the Grains/Cereals category. (Hint: Use MAX) The product ID, product name, and number of distinct customers who ordered that product in 1996 Thank you. Categories Customers Employees Order Details Orders Products Shippers 9 CategoryID CategoryName Description...

  • Project Steps: 1. Database Design 1.1. Design and create a database in third normal form based...

    Project Steps: 1. Database Design 1.1. Design and create a database in third normal form based on the following requirements: • Each Job is for a specific customer and there can be more than one job per customer. • The name and address must be tracked for each customer. • Each job is described by up to 2000 characters. • Each job has a status of ‘open, ‘in process’, or ‘complete’. • Each job has a start date and end...

  • K3 K3 School of CS & IT, RMIT Introduction to Database Systems Tutorial Sheet 2: SQL...

    K3 K3 School of CS & IT, RMIT Introduction to Database Systems Tutorial Sheet 2: SQL The database below is for a department store, and describes stock, staff, clients, and sales. Each question in this tutorial concerns this "store" database. SALE ITEM ITEM STAFF NUMSOLD CLIENT SDATE TYPE DESCRIP PRICE K3 Simon 6 Clark 19980311 Knife set $17.95 K11 Simon Cilla 19980121 K5 Ladle $6.95 K11 Simon Cilla 19980123 K11 Scraper $0.95 L12 Sorcha 5 Charles 19971130 L12 Rack $22.95...

  • The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind...

    The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind Traders, which imports and exports specialty foods from around the world. Here is the schema of the database: Products (ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued); Suppliers (SupplierID, CompanyName, ContactName , ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage); Categories (CategoryID, CategoryName, Description, Picture); Orders (OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia,  Freight, ShipName,ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry); Order_details (ID, OrderID,...

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