0% found this document useful (0 votes)
16 views4 pages

Week7 - Assignment 1 - Set3 Wednesday - Sol

The document outlines a lab assignment for the BTech course on Information Management System, focusing on a Pizza Order Management System. It includes objectives for students to learn subqueries and various operators, along with a detailed scenario of a pizza shop in New Delhi, customer and item data, and SQL queries for different tasks. The assignment emphasizes the need for an automated system to improve customer service and data management in the pizza shop.

Uploaded by

Niharika Keshari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Week7 - Assignment 1 - Set3 Wednesday - Sol

The document outlines a lab assignment for the BTech course on Information Management System, focusing on a Pizza Order Management System. It includes objectives for students to learn subqueries and various operators, along with a detailed scenario of a pizza shop in New Delhi, customer and item data, and SQL queries for different tasks. The assignment emphasizes the need for an automated system to improve customer service and data management in the pizza shop.

Uploaded by

Niharika Keshari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

School of Computer Science Engineering and Technology

Course- BTech Type- Core


Course Code- CSET201 Course Name- Information Management
System (Lab)
Year- 2025 Semester- Odd
Date- 10/09/2025 Batch- 2024-2028

Type- Lab Assignment No. (Week 7, Assignment No. 6)

CO-Mapping
Question No. CO1 CO2 CO3
Q1 - - 
Q2 - - 
Q3 - - 
Q4 - - 
Q5 -
- 
Q6 - - 
Q7 - - 
Q8 - - 

Objectives
1. Student will be able to learn how to use the concept of subqueries
2. Student will be able to practice operators: In , Not In, Exists, Not Exists, All, Any.

Problem: Pizza Order Management System

Pizza shop are the shops where there is a facility of take away and dine in is there. There is need for
efficient service delivery in the pizza shop as all love pizza. They can’t wait for much time to eat it. As a
result of this there is need for a online system that will enable its management making effective and
efficient decision. Recently, efforts are continuously being made in designing and constructing a user
friendly and reliable database system to satisfy customer need.
School of Computer Science Engineering and Technology
Goal:
It aimed at designing and implementing an automated pizza sale system that will alleviate the problem of
handling customer data in the shop poor file retrieval system and inefficient file update system etc. This
examines an existing information system of pizza shop and designed an automated system that can help
the customer to order the pizza easily and get their bills timely without extra waiting. The Database
would be developed with MySQL software.

Description of Scenario:
One Pizza shop running in New delhi where the demand of pizza sale is tremendous. Multiple customer
visits the shop whole day. The timing of pizza shop is from 10:00 AM to 11:00 PM. Customer visiting to
purchase pizza has to give his basic details for registration like mobile number as customer id and his
name. The mobile number has to to be entered as integer data type and customer name as string datatype.
There are variety of pizza available in the shop. Each pizza has unique id and name. The prices of all
available pizza also varies but might be same as well for few of them. The datatype of pizza id and price
is integer, and pizza name is string.
When customer purchases the pizza, customer recieves a bill for his purchase. That bill contains multiple
information related to that purchase like bill number, bill date, customer id, item unique id, and quantity
of pizza sold.

Assumptions:
1. Customer id, item id, and bill number should be unique.
2. All the table should contain 10 records.
3. The format of bill date should be DATE.

Customers
CustId CustomerName
123 Ramesh
243 Prabhu
456 Rohit
875 Samuel
978 Urvashi
544 Vandana
867 Sarvesh
837 Mohit

Datatypes used: Customer(CustId: integer, CustomerName: varchar(255))

Items
ItemID ItemName Price
13 Neapolitan Pizza 1200
24 Chicago Pizza 1300
36 New York-Style Pizza 1000
35 Sicilian Pizza 2000
78 Detroit Pizza 799
74 St. Louis Pizza 899
57 California Pizza 2199
99 Greek Pizza 1300

Datatypes used: Item(ItemID: integer, ItemName: varchar, Price: integer)


School of Computer Science Engineering and Technology
Sales

BillNo BillDate, CustID, ItemID, QtySold


457568 1-AUG-22 123 99 2
324235 3-AUG-22 243 57 3
967643 5-AUG-22 456 74 1
457568 6-AUG-22 875 78 3
767879 8-AUG-22 978 35 4
234325 9-AUG-22 544 36 1
656878 10-AUG-22 867 24 2
789780 16-AUG-22 837 13 3

Datatypes used: Sale(BillNo integer, BillDate varchar(255), CustID integer, ItemID integer, QtySold
integer)

Questions:
Q1) Customers who bought more total pizzas than the average per-customer quantity.

SELECT CustID, CustomerName


FROM Customers
WHERE CustID IN (
SELECT CustID
FROM Sales
GROUP BY CustID
HAVING SUM(QtySold) >
(SELECT AVG(t.total_qty)
FROM (SELECT CustID, SUM(QtySold) AS total_qty
FROM Sales
GROUP BY CustID) t)
);

Q2) Items priced above the overall average price.

SELECT ItemID, ItemName, Price


FROM Items
WHERE Price > (SELECT AVG(Price) FROM Items);

Q3) Sales rows with quantity greater than the minimum sold across all sales.

SELECT *
FROM Sales
WHERE QtySold > (SELECT MIN(QtySold) FROM Sales);

Q4) Customers who purchased the same item(s) as 'Mohit'

SELECT DISTINCT c.CustID, c.CustomerName


FROM Customers c
WHERE c.CustID IN (
SELECT s.CustID
FROM Sales s
WHERE s.ItemID IN (
SELECT ItemID
FROM Sales
School
WHERE CustID of Computer
= (SELECT CustID FROMScience Engineering
Customers WHERE and=Technology
CustomerName 'Mohit')
)
);

Q5) Show the id, name and price of Most expensive item(s).

SELECT ItemID, ItemName, Price


FROM Items
WHERE Price = (SELECT MAX(Price) FROM Items);

Q6) Customers who have never bought the cheapest item(s) (uses NOT EXISTS)

SELECT c.CustID, c.CustomerName


FROM Customers c
WHERE NOT EXISTS (
SELECT 1
FROM Sales s
JOIN Items i ON i.ItemID = s.ItemID
WHERE s.CustID = c.CustID
AND i.Price = (SELECT MIN(Price) FROM Items)
);

Q7) Sales where the item’s price is higher than every item Mohit ever bought (uses ALL)

SELECT s.*
FROM Sales s
JOIN Items i ON i.ItemID = s.ItemID
WHERE i.Price > ALL (
SELECT i2.Price
FROM Sales s2
JOIN Items i2 ON i2.ItemID = s2.ItemID
WHERE s2.CustID = (SELECT CustID FROM Customers WHERE CustomerName = 'Mohit')
);

Q8) Correlated subquery: customers whose first purchase date is the earliest among all customers

{Treat BillDate as comparable text (as per given data); if it's DATE, cast appropriately.}

SELECT c.CustID, c.CustomerName


FROM Customers c
WHERE (SELECT MIN(BillDate) FROM Sales s WHERE s.CustID = c.CustID)
= (SELECT MIN(BillDate) FROM Sales);

You might also like