Question Paper
Restaurant Billing System (Database)
Section A: Problem Scenario
A restaurant billing system uses a database to store and manage billing information. It consists of
three tables:
1. Customer: Stores customer details.
2. OrderDetails: Stores order details placed by customers.
3. MenuItem: Contains the food items and prices available on the menu.
The relationships are:
Each customer can place multiple orders.
Each order consists of one or more menu items.
Foreign keys establish relationships among these tables.
Section B: Table Structures
1. Customer Table
Column Name Data Type Constraints
CustomerID INT PRIMARY KEY
Name VARCHAR(50) NOT NULL
Phone VARCHAR(15) UNIQUE
Email VARCHAR(50) UNIQUE
2. MenuItem Table
Column Name Data Type Constraints
ItemID INT PRIMARY KEY
ItemName VARCHAR(50) NOT NULL
Price DECIMAL(8,2) NOT NULL
3. OrderDetails Table
Column Name Data Type Constraints
OrderID INT PRIMARY KEY
CustomerID INT FOREIGN KEY REFERENCES Customer(CustomerID)
ItemID INT FOREIGN KEY REFERENCES MenuItem(ItemID)
Quantity INT CHECK (Quantity > 0)
OrderDate DATE DEFAULT CURRENT_DATE
Section C: SQL Queries
Write SQL queries to perform the following tasks:
1. Insert Records
o Add 3 customers into the Customer table.
o Add 5 menu items into the MenuItem table.
o Add at least 4 orders into the OrderDetails table.
2. Retrieve All Data
o Retrieve all records from the Customer table, ordered by Name.
3. Join Query
o Retrieve the customer name, item name, quantity, and order date for all orders
by joining the necessary tables.
4. Total Bill for Each Order
o Write a query to calculate the total bill (Price * Quantity) for each order placed.
Display OrderID and the total bill amount.
5. Customer-Specific Orders
o Retrieve all orders placed by a specific customer. Use the CustomerID or Name
for filtering.
6. Orders Placed on a Specific Date
o Write a query to display all orders placed on '2024-04-01'.
7. Most Expensive Menu Item
o Find and display the details of the most expensive menu item.
8. Total Quantity Ordered Per Item
o Write a query to display the item name and the total quantity ordered for each
item.
Instructions to Students
1. Use proper SQL syntax and test each query.
2. Clearly state assumptions, if any.
3. Attempt all queries; partial answers will receive partial credit.