Uploaded by Vamsi Prasad

Restaurant Management System ERD & Use Cases

advertisement
1
Restaurant Management System
For the Restaurant Management System, The ERD shows the different entities (tables) in the
system and how they are connected to each other. It is a visual representation of how the data is
organized and how different tables interact.
Entities and Relationships
Entities (Tables) and Their Fields
1. Customer
- Stores information about restaurant customers.
Fields:
CustomerID (Primary Key): A unique ID for each customer.
FirstName: Customer's first name.
LastName: Customer's last name.
Email: Customer’s email address.
PhoneNumber: Customer’s phone number.
LoyaltyPoints: Total reward points earned by the customer.
2. Menu
- Stores details of food items available in the restaurant.
Fields:
MenuID (Primary Key): A unique ID for each menu item.
DishName: Name of the dish (e.g., Masala Dosa, Biryani).
Category: Type of dish (e.g., Starter, Main Course, Dessert).
Price: Cost of the dish.
3. Order
- Stores customer orders, each containing multiple menu items.
2
Restaurant Management System
Fields:
OrderID (Primary Key): A unique ID for each order.
CustomerID (Foreign Key → Customer): The customer who placed the order.
OrderDate: Date of order.
TotalAmount: Total cost of the order.
OrderStatus: Status (e.g., Pending, Completed, Cancelled).
4. OrderDetails
- Links orders to menu items, recording quantities of each item.
Fields:
OrderDetailID (Primary Key): A unique ID for each order detail.
OrderID (Foreign Key → Order): The order to which this detail belongs.
MenuID (Foreign Key → Menu): The dish ordered.
Quantity: How many of this dish were ordered.
Subtotal: Price of the dish multiplied by quantity.
5. TableBooking
- Stores information about table reservations in the restaurant.
Fields:
BookingID (Primary Key): A unique ID for each booking.
CustomerID (Foreign Key → Customer): The customer who booked the table.
TableNumber: The table assigned to the customer.
BookingDate: The date of the booking.
BookingTime: Time slot of the reservation.
Status: Status of booking (Confirmed, Cancelled).
3
Restaurant Management System
6. Staff
- Stores details of restaurant employees.
Fields:
StaffID (Primary Key): A unique ID for each staff member.
FirstName: Staff member's first name.
LastName: Staff member's last name.
Role: Job role (e.g., Chef, Waiter, Manager).
Salary: Monthly salary.
PhoneNumber: Contact number.
7. Payment
- Stores payment information for orders.
Fields:
PaymentID (Primary Key): A unique ID for each payment.
OrderID (Foreign Key → Order): The order for which payment was made.
PaymentDate: Date of payment.
PaymentMethod: Mode of payment (Cash, Card, UPI).
AmountPaid: Amount paid by the customer.
8. Bill
- Stores billing details for each order.
Fields:
BillID (Primary Key): A unique ID for each bill.
OrderID (Foreign Key → Order): The order associated with the bill.
TotalAmount: Total cost before discount.
4
Restaurant Management System
DiscountApplied: Discount applied to the bill.
FinalAmount: Total cost after discount.
BillDate: Date the bill was generated.
9. Promotion
- Stores promotional discounts for customers.
Fields:
PromotionID (Primary Key): A unique ID for each promotion.
DiscountPercentage: Percentage of discount offered.
StartDate: Start date of the promotion.
EndDate: End date of the promotion.
Description: Brief details of the promotion.
10. RewardPoints
- Stores customer reward points earned from orders.
Fields:
RewardID (Primary Key): A unique ID for each reward entry.
CustomerID (Foreign Key → Customer): The customer earning the points.
Points: Number of points earned.
EarnedDate: Date the points were added.
11. Supplier
- Stores information about suppliers who provide ingredients for the restaurant.
Fields:
SupplierID (Primary Key): A unique ID for each supplier.
SupplierName: Name of the supplier.
5
Restaurant Management System
PhoneNumber: Contact number.
Address: Address of the supplier.
12. Inventory
- Stores details of restaurant ingredients and stock.
Fields:
InventoryID (Primary Key): A unique ID for each inventory item.
ItemName: Name of the ingredient (e.g., Rice, Flour).
Quantity: Amount available in stock.
SupplierID (Foreign Key → Supplier): The supplier of the ingredient.
Relationships Between Entities
1. Customer ↔ Order
- A Customer can place many Orders.
- Each Order is linked to one Customer.
2. Order ↔ OrderDetails
- An Order can have many OrderDetails (each for a different dish).
- Each OrderDetail is linked to one Order.
3. Menu ↔ OrderDetails
- A Menu item can appear in multiple OrderDetails.
- Each OrderDetail contains only one Menu item.
4. Customer ↔ RewardPoints
- A Customer can have multiple RewardPoints entries.
- Each RewardPoints entry belongs to one Customer.
6
Restaurant Management System
5. Order ↔ Payment
- Each Order has one Payment.
- A Payment is linked to one Order.
6. Order ↔ Bill
- An Order generates one Bill.
- Each Bill belongs to only one Order.
7. Promotion ↔ Order
- If a Promotion is applied, the Order references the Promotion.
- Not all orders may have a promotion.
8. Staff ↔ Order
- A Staff member (Waiter) is responsible for handling an Order.
9. Supplier ↔ Inventory
- Each Inventory item is supplied by one Supplier.
- A Supplier can provide multiple Inventory items.
7
Restaurant Management System
Entity-Relationship Diagram
Use Cases Implemented
1. Place an Order
- Description: This use case allows a customer to place an order for food items at the restaurant.
The order is recorded in the system and sent to the kitchen for preparation.
- Actors Involved: Customer, Waiter, System
- Steps:
1. The customer provides their order to the waiter.
2. The waiter enters the order into the system.
3. The system checks the availability of menu items.
4. If items are available, the order is recorded in the database.
5. The system sends the order details to the kitchen.
6. The kitchen staff prepares the food.
7. Once prepared, the order status is updated to "Completed."
8. A notification is sent to the waiter for delivery.
8
Restaurant Management System
2. Process a Payment
- Description: This use case allows a customer to pay for their completed order using various
payment methods such as cash, card, or UPI.
- Actors Involved: Customer, Cashier, System
- Steps:
9
Restaurant Management System
1. The cashier retrieves the customer’s bill from the system.
2. The customer selects a payment method.
3. The system processes the payment.
4. If successful, the system updates the order status to "Paid."
5. A receipt is generated and provided to the customer.
10
Restaurant Management System
3. Book a Table
- Description: This use case allows customers to reserve a table at the restaurant in advance
based on availability.
- Actors Involved: Customer, System
- Steps:
11
Restaurant Management System
1. The customer requests a table reservation, providing date, time, and number of guests.
2. The system checks table availability.
3. If a table is available, the system reserves it and records the booking details.
4. A confirmation message is sent to the customer.
4. Manage Inventory
- Description: This use case allows the restaurant manager to track and update inventory levels
for food and beverages.
- Actors Involved: Manager, System
12
Restaurant Management System
- Steps:
1. The manager logs into the system.
2. The manager views current inventory levels.
3. If stock is low, the manager places a restocking order.
4. The system records the restocking request and notifies the supplier.
5. When new stock arrives, the system updates inventory levels.
6. A confirmation message is displayed to the manager.
13
Restaurant Management System
14
Restaurant Management System
Test Cases
1. Place an Order
Positive Test Cases (Valid Scenarios)
1. Place a valid order
- Customer selects available food items.
- Waiter enters order correctly.
- System confirms items are available and sends order to the kitchen.
- Kitchen prepares food, and status updates to "Completed."
- Waiter gets notification for delivery.
2. Order multiple items
- Customer orders more than one item.
- System processes all items correctly.
3. Order special items (custom requests)
- Customer requests "no spice" or "extra cheese."
- System allows special instructions.
- Kitchen receives correct details.
4. Order food when the restaurant is open
- System only allows orders during restaurant hours.
5. Order confirmation message
- System displays "Order Placed" after successful order entry.
6. Order tracking updates
15
Restaurant Management System
- System updates status (e.g., "Preparing," "Completed").
MySQL code
-- Create Customers Table
CREATE TABLE Customers (
customer_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
phone VARCHAR(15) NOT NULL UNIQUE,
email VARCHAR(100) UNIQUE
);
-- Create Menu Table
CREATE TABLE Menu (
item_id INT AUTO_INCREMENT PRIMARY KEY,
item_name VARCHAR(100) NOT NULL,
price DECIMAL(10,2) NOT NULL,
available BOOLEAN DEFAULT TRUE
16
Restaurant Management System
);
-- Create Orders Table
CREATE TABLE Orders (
order_id INT AUTO_INCREMENT PRIMARY KEY,
customer_id INT,
order_status ENUM('Placed', 'Preparing', 'Completed', 'Cancelled') DEFAULT 'Placed',
order_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (customer_id) REFERENCES Customers(customer_id)
);
17
Restaurant Management System
-- Create Order Items Table
CREATE TABLE Order_Items (
order_item_id INT AUTO_INCREMENT PRIMARY KEY,
order_id INT,
item_id INT,
quantity INT CHECK(quantity > 0),
special_request VARCHAR(255) DEFAULT NULL,
FOREIGN KEY (order_id) REFERENCES Orders(order_id),
FOREIGN KEY (item_id) REFERENCES Menu(item_id)
);
-- Insert Sample Data for Testing
INSERT INTO Customers (name, phone, email) VALUES
('John Wick', '1234567890', 'john@example.com');
INSERT INTO Menu (item_name, price, available) VALUES
18
Restaurant Management System
('Pizza', 12.99, TRUE),
('Pasta', 9.99, TRUE),
('Burger', 7.99, TRUE);
-- Place a valid order
INSERT INTO Orders (customer_id) VALUES (1);
-- Order multiple items
INSERT INTO Order_Items (order_id, item_id, quantity, special_request) VALUES
(1, 1, 1, 'Extra cheese'), -- Pizza with extra cheese
(1, 2, 2, NULL); -- 2 Pasta orders
-- Update order status to 'Preparing'
UPDATE Orders SET order_status = 'Preparing' WHERE order_id = 1;
19
Restaurant Management System
-- Update order status to 'Completed' after preparation
UPDATE Orders SET order_status = 'Completed' WHERE order_id = 1;
-- Track order status
SELECT order_id, order_status, order_time FROM Orders WHERE order_id = 1;
20
Restaurant Management System
Negative Test Cases (Invalid Scenarios)
1. Order unavailable items
- Customer orders an item that is out of stock.
- System shows a message: "Item not available."
2. Waiter enters incorrect order
- System prevents placing an empty or incorrect order.
3. Place order when restaurant is closed
- Customer tries to order after hours.
- System shows "Restaurant is closed."
4. Kitchen does not receive order
- Order is placed, but kitchen does not get it.
- System should detect and notify staff.
5. Internet or system failure
- System crashes while entering an order.
- Order should not be lost.
6. Duplicate order issue
- Same order is placed twice by mistake.
- System should prevent duplicate entries.
7. Customer cancels an order after it is prepared
- System should not allow canceling food already prepared.
8. Insufficient ingredients
- Kitchen cannot prepare food due to missing ingredients.
- System should update inventory and alert staff.
21
Restaurant Management System
MySQL code
-- Mark an item as unavailable
SET SQL_SAFE_UPDATES = 0; UPDATE Menu SET available = FALSE WHERE item_name
= 'Sushi'; SET SQL_SAFE_UPDATES = 1;
-- Attempt to order an unavailable item
SELECT CASE
WHEN available = FALSE THEN 'Item not available'
ELSE 'Proceed with order'
END AS message
FROM Menu WHERE item_name = 'Sushi';
22
Restaurant Management System
-- Prevent empty or incorrect orders
ALTER TABLE Order_Items ADD CONSTRAINT chk_quantity CHECK (quantity > 0);
-- Prevent loss of orders in case of system failure (Use transactions)
START TRANSACTION;
INSERT INTO Orders (customer_id) VALUES (2);
INSERT INTO Order_Items (order_id, item_id, quantity) VALUES (LAST_INSERT_ID(), 3,
1);
COMMIT;
-- Prevent duplicate orders
ALTER TABLE Orders ADD UNIQUE (customer_id, order_time);
23
Restaurant Management System
-- Restrict canceling after preparation
DELIMITER //
CREATE TRIGGER prevent_cancel_after_prepared
BEFORE UPDATE ON Orders
FOR EACH ROW
BEGIN
IF OLD.order_status = 'Completed' AND NEW.order_status = 'Cancelled' THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Cannot cancel a prepared order';
END IF;
END;
//
DELIMITER ;
-- Handle insufficient ingredients (Example: Update stock)
ALTER TABLE Menu ADD COLUMN stock INT DEFAULT 10;
UPDATE Menu SET stock = 0 WHERE item_name = 'Spicy Tacos';
24
Restaurant Management System
-- Prevent ordering items with no stock
DELIMITER //
CREATE TRIGGER check_stock_before_order
BEFORE INSERT ON Order_Items
FOR EACH ROW
BEGIN
DECLARE item_stock INT;
SELECT stock INTO item_stock FROM Menu WHERE item_id = NEW.item_id;
IF item_stock < NEW.quantity THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Insufficient ingredients';
END IF;
END;
//
DELIMITER ;
2. Process a Payment
25
Restaurant Management System
Positive Test Cases (Valid Scenarios)
1. Successful cash payment
- Cashier retrieves the bill.
- Customer pays with cash.
- System marks order as "Paid" and gives receipt.
2. Successful card payment
- Customer selects a debit/credit card.
- System processes the payment successfully.
- Order status updates to "Paid," and receipt is given.
3. Successful UPI payment
- Customer scans UPI code and pays.
- Payment is processed and verified.
- Order is marked "Paid," and receipt is provided.
4. Exact bill amount is paid
- Customer pays the exact amount.
- No change is needed, and payment is completed.
5. Bill is retrieved correctly
- Cashier enters order number.
- System shows the correct bill details.
6. Payment confirmation message
- System displays "Payment Successful" after successful processing.
MySQL Code
-- Table for storing payments
26
Restaurant Management System
CREATE TABLE Payments (
payment_id INT AUTO_INCREMENT PRIMARY KEY,
order_id INT NOT NULL,
customer_id INT NOT NULL,
payment_method ENUM('Cash', 'Card', 'UPI') NOT NULL,
amount DECIMAL(10,2) NOT NULL,
payment_status ENUM('Pending', 'Paid', 'Failed') DEFAULT 'Pending',
transaction_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (order_id) REFERENCES Orders(order_id),
FOREIGN KEY (customer_id) REFERENCES Customers(customer_id)
);
-- Successful cash payment
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (101, 5, 'Cash', 120.50, 'Paid');
27
Restaurant Management System
UPDATE Orders SET order_status = 'Paid' WHERE order_id = 101;
SELECT 'Receipt Generated' AS message;
-- Successful card payment
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (102, 8, 'Card', 250.00, 'Paid');
UPDATE Orders SET order_status = 'Paid' WHERE order_id = 102;
SELECT 'Payment Successful - Receipt Generated' AS message;
28
Restaurant Management System
-- Successful UPI payment
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (103, 12, 'UPI', 300.75, 'Paid');
UPDATE Orders SET order_status = 'Paid' WHERE order_id = 103;
SELECT 'UPI Payment Verified - Receipt Generated' AS message;
29
Restaurant Management System
UPDATE Orders SET order_status = 'Paid' WHERE order_id = 104;
SELECT 'Exact Amount Received - No Change Needed' AS message;
-- Retrieve bill correctly
SELECT order_id, amount, payment_method, payment_status
FROM Payments WHERE order_id = 101;
Negative Test Cases (Invalid Scenarios)
1. Card payment fails
- Customer enters wrong PIN or card is declined.
- System shows "Payment Failed."
30
Restaurant Management System
- Order remains "Unpaid."
2. UPI transaction timeout
- UPI payment takes too long.
- System shows "Transaction Timeout."
- Order is not marked as "Paid."
3. Customer pays less than bill amount
- System does not allow partial payment.
- Order remains "Unpaid."
4. Customer pays with fake currency
- Cashier detects fake notes.
- System does not mark order as "Paid."
5. System crashes during payment
- Payment is deducted, but system does not update order.
- System should retry or allow manual confirmation.
6. Printer issue when generating receipt
- Payment is successful, but receipt does not print.
- System should allow reprinting.
7. Payment processed, but order not updated
- System accepts money but does not update status to "Paid."
- Cashier should manually verify and correct the issue.
8. Customer cancels payment after it starts
- Customer changes mind after payment is initiated.
- System should cancel payment properly and keep order "Unpaid."
31
Restaurant Management System
MySQL Code
-- Failed card payment (wrong PIN, declined card)
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (201, 15, 'Card', 500.00, 'Failed');
SELECT 'Payment Failed - Please try again' AS message;
UPDATE Orders SET order_status = 'Unpaid' WHERE order_id = 201;
-- UPI transaction timeout
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (202, 18, 'UPI', 250.00, 'Failed');
32
Restaurant Management System
SELECT 'Transaction Timeout - Payment Not Received' AS message;
UPDATE Orders SET order_status = 'Unpaid' WHERE order_id = 202;
-- Customer pays less than the bill amount
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (203, 22, 'Cash', 180.00, 'Failed');
SELECT 'Payment Rejected - Insufficient Amount' AS message;
UPDATE Orders SET order_status = 'Unpaid' WHERE order_id = 203;
33
Restaurant Management System
-- Fake currency detected
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (204, 25, 'Cash', 300.00, 'Failed');
SELECT 'Payment Failed - Fake Currency Detected' AS message;
UPDATE Orders SET order_status = 'Unpaid' WHERE order_id = 204;
-- System crashes during payment (payment deducted but order not updated)
34
Restaurant Management System
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (205, 30, 'Card', 400.00, 'Processing');
SELECT 'System Error - Payment Processing, Verify Manually' AS message;
-- Printer issue when generating receipt
UPDATE Payments SET payment_status = 'Paid' WHERE order_id = 206;
SELECT 'Payment Successful - Receipt Printing Failed. Please Retry' AS message;
35
Restaurant Management System
-- Payment processed but order status not updated
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (207, 35, 'UPI', 600.00, 'Paid');
SELECT 'Warning: Payment Received but Order Not Updated' AS message;
-- Cashier manually verifies and updates order status
UPDATE Orders SET order_status = 'Paid' WHERE order_id = 207;
-- Customer cancels payment after initiation
INSERT INTO Payments (order_id, customer_id, payment_method, amount, payment_status)
VALUES (208, 40, 'Card', 450.00, 'Cancelled');
36
Restaurant Management System
SELECT 'Payment Cancelled - Order Remains Unpaid' AS message;
UPDATE Orders SET order_status = 'Unpaid' WHERE order_id = 208;
Download