0% found this document useful (0 votes)
26 views54 pages

Dbms Final Report Mulinch

This document is a microproject report on an Online Food Delivery system submitted by students Pradnya Manakoji and Jiya Tamboli for their Diploma in Computer Technology at Government Polytechnic, Solapur. It includes a literature review, ER diagrams, normalization processes, SQL commands, and constraints for database management. The project aims to enhance the user experience in online food ordering through improved features and functionalities.

Uploaded by

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

Dbms Final Report Mulinch

This document is a microproject report on an Online Food Delivery system submitted by students Pradnya Manakoji and Jiya Tamboli for their Diploma in Computer Technology at Government Polytechnic, Solapur. It includes a literature review, ER diagrams, normalization processes, SQL commands, and constraints for database management. The project aims to enhance the user experience in online food ordering through improved features and functionalities.

Uploaded by

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

Maharashtra State Board of

Technical Education, Mumbai

Government Polytechnic, Solapur

DIPLOMA IN COMPUTER TECHNOLOGY

ACEDAMIC YEAR 2024-2025

A
MICROPROJECT REPORT ON
Online Food Delivery
Submitted by: -
Roll Enrolment Name
number number
31 23210230250 Pradnya Mahadev Manakoji
95 23210230319 Jiya Jakir Tamboli

Submitted to: - Prof. Ravi Gangundi


1
2
CERTIFICATE
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION, MUMBAI

GOVERNMENT POLYTECHNIC, SOLAPUR

Title of microproject- Online Food Delivery

This is to certify that the following students Pradnya Manakoji ,


Jiya Tamboli Roll no 31,95 enrolments no 23210230250 and
23210230319 of Branch Computer of semester third (3) of
diploma in Computer Technology of institute Goverment
Polytechnic, Solapur. Code (0015) have completed the
microproject work satisfactorily under my supervision /guidance
for the subject DATABASE MANAGEMENT SYSTEM in the
academic year 2024-2025 as prescribed in the curriculum.

Guide Name -Prof. Gangundi sir

Date & Sign -

HOD PRINCIPAL

3
CONTENTS:

Sr No. CONTENTS

1. INTRODUCTION

2. ER DIAGRAM

3. NORMALIZATION :

4. FINAL TABLE:

5. CONSTRAINTS:

6. COMMANDS

7. SQL COMMANDS FOR DML OPERATIONS ON

TABLE

8. PL-SQL

9. Resources used

10. CONCLUSION

4
INTRODUCTION:
Literature Review:
Online food ordering systems have gained widespread popularity,
allowing customers to order food through websites or mobile apps,
offering convenience and efficiency. These systems typically include
features like menu browsing, order placement, and the choice of
delivery or pick-up. Research has focused on improving aspects like
user experience, payment security, and order tracking. Advances
include the use of AI for personalized recommendations and cloud-
based platforms for scalability and real-time order updates. Popular
platforms today allow customers to place orders through apps,
websites, or third-party services, improving accessibility.

Existing System Studied:


Domino's is a well-known example of a successful online food ordering
system. It allows customers to easily browse the menu, customize
their orders, and choose delivery or pick-up options. Customers can
pay via cash, credit card, or digital wallets. While Domino's offers a
seamless ordering process, challenges such as high traffic during peak
hours and the lack of advanced personalization in recommendations
remain. Despite these issues, Domino’s system offers real-time order
tracking, which enhances customer satisfaction and transparency.

5
ER MODELS FOR ENTITY:

6
7
ER MODEL FOR RELATIONSHIP:

8
NORMALIZATION TABLES:

Normal Changes Made Key Dependencies


Form
1NF Ensured atomicity and Each attribute is dependent on its
primary keys primary key.
2NF Eliminated partial Non-key attributes are fully dependent
dependevncies on the entire primary key.
3NF Removed transitive Non-key attributes only depend on the
dependencies primary key.

1. First Normal Form (1NF)


To make sure each table is in 1NF, we ensure that:
• All columns have atomic values (no multi-valued or composite
attributes).
• There are no repeating groups.

Restaurants Table (1NF)


Column Data Type Description
Name
restaurant_id NUMBER(5) Primary Key
name VARCHAR2(100) Name of the restaurant (NOT
NULL)
location VARCHAR2(50) Location of the restaurant
contact VARCHAR2(20) Contact number of the restaurant
• All columns contain atomic (indivisible) values, e.g., restaurant_id,
name, location, and contact.
• There are no repeating groups or multi-valued attributes in the table.

Food_Items Table (1NF)

9
Column Data Type Description
Name
food_id NUMBER(5) Primary Key
restaurant_id NUMBER(5) Foreign Key (references
Restaurants.restaurant_id)
name VARCHAR2(100) Name of the food item (NOT NULL)
description VARCHAR2(50) Description of the food item
price DECIMAL(10,2) Price of the food item (NOT NULL)
category VARCHAR2(50) Category of the food item
• All columns contain atomic values, e.g., food_id, restaurant_id, name,
description, price, and category.
• There are no repeating groups in the table.

Customers Table (1NF)


Column Name Data Type Description
customer_id NUMBER(5) Primary Key
name VARCHAR2(100) Name of the customer (NOT NULL)
email VARCHAR2(100) Email address (optional)
phone VARCHAR2(20) Phone number (optional)
address VARCHAR2(50) Address of the customer (optional)
• All columns contain atomic values, e.g., customer_id, name, email,
phone, and address.
• There are no repeating groups or multi-valued attributes.

Orders Table (1NF)

10
Column Data Type Description
Name
order_id NUMBER(10) Primary Key
customer_id NUMBER(5) Foreign Key (references
Customers.customer_id)
restaurant_id NUMBER(5) Foreign Key (references
Restaurants.restaurant_id)
order_date DATE Date when the order was placed
status VARCHAR2(20) Status of the order (default: 'pending')
• All columns contain atomic values, e.g., order_id, customer_id,
restaurant_id, order_date, and status.
• There are no repeating groups or multi-valued attributes.

Order_Items Table (1NF)


Column Data Type Description
Name
order_item_id NUMBER(5) Primary Key
order_id NUMBER(5) Foreign Key (references Orders.order_id)
food_id NUMBER(5) Foreign Key (references
Food_Items.food_id)
quantity NUMBER(5) Quantity of the food item ordered (NOT
NULL)
• All columns contain atomic values, e.g., order_item_id, order_id,
food_id, and quantity.
• There are no repeating groups or multi-valued attributes.

Billing Table (1NF)


Column Name Data Type Description

11
billing_id NUMBER(5) Primary Key
order_id NUMBER(5) Foreign Key (references
Orders.order_id)
billing_date DATE Date when the billing was created
payment_method VARCHAR2(50) Method of payment (e.g., Credit
Card, Cash, etc.)
• All columns contain atomic values, e.g., billing_id, order_id,
billing_date, and payment_method.
• There are no repeating groups or multi-valued attributes.

2. Second Normal Form (2NF)


To make sure each table is in 2NF, we need to:
• Ensure the table is in 1NF.
• Eliminate partial dependencies, meaning that every non-key attribute
must depend on the entire primary key (not just part of it).

Restaurants Table (2NF)


Column Data Type Description
Name
restaurant_id NUMBER(5) Primary Key
name VARCHAR2(100) Name of the restaurant (NOT
NULL)
location VARCHAR2(50) Location of the restaurant
contact VARCHAR2(20) Contact number of the restaurant
• All non-key attributes (name, location, contact) depend on the entire
primary key (restaurant_id), so there are no partial dependencies.

Food_Items Table (2NF)

12
Column Data Type Description
Name
food_id NUMBER(5) Primary Key
restaurant_id NUMBER(5) Foreign Key (references
Restaurants.restaurant_id)
name VARCHAR2(100) Name of the food item (NOT NULL)
description VARCHAR2(50) Description of the food item
price DECIMAL(10,2) Price of the food item (NOT NULL)
category VARCHAR2(50) Category of the food item
• All non-key attributes depend on the entire primary key (food_id), so
there are no partial dependencies.

Customers Table (2NF)


Column Data Type Description
Name
customer_id NUMBER(5) Primary Key
First_name VARCHAR2(100) First Name of the customer (NOT
NULL)
Last_name VARCHAR2(100) Last name of the customer (NOT
NULL).
email VARCHAR2(100) Email address (optional)
phone VARCHAR2(20) Phone number (optional)
address VARCHAR2(50) Address of the customer (optional)
• All non-key attributes (First_name,Last_name, email, phone, address)
depend on the entire primary key (customer_id), so there are no partial
dependencies.

13
Orders Table (2NF)
Column Data Type Description
Name
order_id NUMBER(10) Primary Key
customer_id NUMBER(5) Foreign Key (references
Customers.customer_id)
restaurant_id NUMBER(5) Foreign Key (references
Restaurants.restaurant_id)
order_date DATE Date when the order was placed
status VARCHAR2(20) Status of the order (default: 'pending')
• All non-key attributes (customer_id, restaurant_id, order_date, status)
depend on the entire primary key (order_id), so there are no partial
dependencies.

Order_Items Table (2NF)


Column Data Type Description
Name
order_item_id NUMBER(5) Primary Key
order_id NUMBER(5) Foreign Key (references Orders.order_id)
food_id NUMBER(5) Foreign Key (references
Food_Items.food_id)
quantity NUMBER(5) Quantity of the food item ordered (NOT
NULL)
• All non-key attributes (order_id, food_id, quantity) depend on the
entire primary key (order_item_id), so there are no partial dependencie

14
Billing Table (2NF)
Column Name Data Type Description
billing_id NUMBER(5) Primary Key
order_id NUMBER(5) Foreign Key (references
Orders.order_id)
billing_date DATE Date when the billing was created
payment_method VARCHAR2(50) Method of payment (e.g., Credit
Card, Cash, etc.)
• All non-key attributes (order_id, billing_date, payment_method)
depend on the entire primary key (billing_id), so there are no partial
dependencies.

3. Third Normal Form (3NF)


To ensure each table is in 3NF, we need to:
• Be in 2NF.
• Eliminate transitive dependencies, meaning no non-key attribute
should depend on another non-key attribute.

Restaurants Table (3NF)


Column Data Type Description
Name
restaurant_id NUMBER(5) Primary Key
name VARCHAR2(100) Name of the restaurant (NOT
NULL)
location VARCHAR2(50) Location of the restaurant
contact VARCHAR2(20) Contact number of the restaurant
• There are no transitive dependencies since name, location, and contact
depend directly on the restaurant_id.

15
Food_Items Table (3NF)
Column Data Type Description
Name
food_id NUMBER(5) Primary Key
restaurant_id NUMBER(5) Foreign Key (references
Restaurants.restaurant_id)
name VARCHAR2(100) Name of the food item (NOT NULL)
description VARCHAR2(50) Description of the food item
price DECIMAL(10,2) Price of the food item (NOT NULL)
category VARCHAR2(50) Category of the food item
• There are no transitive dependencies since all non-key attributes
depend directly on the primary key (food_id).

Customers Table (3NF)


Column Name Data Type Description
customer_id NUMBER(5) Primary Key
name VARCHAR2(100) Name of the customer (NOT NULL)
email VARCHAR2(100) Email address (optional)
phone VARCHAR2(20) Phone number (optional)
address VARCHAR2(50) Address of the customer (optional)
• There are no transitive dependencies since all non-key attributes
depend directly on the primary key (customer_id).

16
Orders Table (3NF)
Column Data Type Description
Name
order_id NUMBER(10) Primary Key
customer_id NUMBER(5) Foreign Key (references
Customers.customer_id)
restaurant_id NUMBER(5) Foreign Key (references
Restaurants.restaurant_id)
order_date DATE Date when the order was placed
status VARCHAR2(20) Status of the order (default: 'pending')
• There are no transitive dependencies since all non-key attributes
depend directly on the primary key (order_id).

Order_Items Table (3NF)


Column Data Type Description
Name
order_item_id NUMBER(5) Primary Key
order_id NUMBER(5) Foreign Key (references Orders.order_id)
food_id NUMBER(5) Foreign Key (references
Food_Items.food_id)
quantity NUMBER(5) Quantity of the food item ordered (NOT
NULL)
• There are no transitive dependencies since all non-key attributes
depend directly on the primary key (order_item_id).

17
Billing Table (3NF)
Column Name Data Type Description
billing_id NUMBER(5) Primary Key
order_id NUMBER(5) Foreign Key (references
Orders.order_id)
billing_date DATE Date when the billing was created
payment_method VARCHAR2(50) Method of payment (e.g., Credit
Card, Cash, etc.)
• There are no transitive dependencies since all non-key attributes
depend directly on the primary key (billing_id).

18
MICROPROJECT OUTPUT:
TABLE FOR RESTAURANT

TABLE FOR FOOD ITEM

19
TABLE FOR ORDERS

TABLE FOR CUSTOMER

20
TABLE FOR BILLING

OUTPUT FOR BILLING SECTION

21
CONSTRAINTS
1. Restaurants
• Primary Key (PK): restaurant_id
• Not Null: name

2. Food_Items
• Primary Key (PK): food_id
• Foreign Key (FK): restaurant_id (References
Restaurants(restaurant_id))
• Not Null: name, price

3. Customers
• Primary Key (PK): customer_id
• Unique: email
• Not Null: name

4. Orders
• Primary Key (PK): order_id
• Foreign Key (FK): customer_id (References
Customers(customer_id)), restaurant_id (References
Restaurants(restaurant_id))

22
• Not Null: order_date, total_amount
• Default: status ('pending')

5. Order_Items
• Primary Key (PK): order_item_id
• Foreign Key (FK): order_id (References
Orders(order_id)), food_id (References
Food_Items(food_id))
• Not Null: quantity

6. Billing
• Primary Key (PK): billing_id
• Foreign Key (FK): order_id (References
Orders(order_id))
• Not Null: billing_date, payment_method, total_amount

23
MICROPROJECT CODE:
CREATE TABLE Restaurants(
restaurant_id number(5) PRIMARY KEY,
name VARCHAR2(100) NOT NULL,
location VARCHAR2(50),
contact VARCHAR2(20)
);

CREATE TABLE Food_Items (


food_id number(5) PRIMARY KEY,
restaurant_id number(5),
name VARCHAR2(100) NOT NULL,
description varchar2(50),
price DECIMAL(10, 2) NOT NULL,
category VARCHAR2(50),
FOREIGN KEY (restaurant_id) REFERENCES Restaurants(restaurant_id)
);

CREATE TABLE Customers (


customer_id number (5) PRIMARY KEY ,
name VARCHAR2(100) NOT NULL,
email VARCHAR2(100),
phone VARCHAR2(20),
address VARCHAR2(50)
);
drop table orders
CREATE TABLE Orders(
order_id number(10) PRIMARY KEY,
customer_id number(5),
restaurant_id number(5),

24
order_date DATE,
total_amount DECIMAL(10, 2),
status VARCHAR2(20) DEFAULT 'pending',
FOREIGN KEY (customer_id) REFERENCES Customers(customer_id),
FOREIGN KEY (restaurant_id) REFERENCES Restaurants(restaurant_id)
);

CREATE TABLE Order_Items (


order_item_id number (5) PRIMARY KEY ,
order_id number(5),
food_id number(5),
quantity number(5) NOT NULL,
subtotal DECIMAL(10, 2),
FOREIGN KEY (order_id) REFERENCES Orders(order_id),
FOREIGN KEY (food_id) REFERENCES Food_Items(food_id)
);
CREATE TABLE Billing (
billing_id number(5) PRIMARY KEY,
order_id number(5),
billing_date DATE,
payment_method VARCHAR2(50),
total_amount DECIMAL(10, 2) NOT NULL, FOREIGN KEY (order_id) REFERENCES
Orders(order_id) );

1. Insert Customers
INSERT ALL
INTO Customers (customer_id, name, email, phone, address) VALUES (11, 'Aarav Sharma',
'[email protected]', '91-9876543210', '101 A-Block, Connaught Place, New Delhi, 110001')

25
INTO Customers (customer_id, name, email, phone, address) VALUES (12, 'Vivaan Gupta',
'[email protected]', '91-8765432109', '202 B-Block, Marine Drive, Mumbai, 400020')
INTO Customers (customer_id, name, email, phone, address) VALUES (13, 'Aditya Patel',
'[email protected]', '91-7654321098', '303 C-Block, Indiranagar, Bangalore, 560038')
INTO Customers (customer_id, name, email, phone, address) VALUES (14, 'Kavya Reddy',
'[email protected]', '91-6543210987', '404 D-Block, Banjara Hills, Hyderabad, 500034')
INTO Customers (customer_id, name, email, phone, address) VALUES (15, 'Ananya Singh',
'[email protected]', '91-5432109876', '505 E-Block, Anna Nagar, Chennai, 600040')
INTO Customers (customer_id, name, email, phone, address) VALUES (16, 'Rohan Mehta',
'[email protected]', '91-4321098765', '606 F-Block, Shivajinagar, Pune, 411005')
INTO Customers (customer_id, name, email, phone, address) VALUES (17, 'Sneha Iyer',
'[email protected]', '91-3210987654', '707 G-Block, Salt Lake, Kolkata, 700091')
INTO Customers (customer_id, name, email, phone, address) VALUES (18, 'Arjun Verma',
'[email protected]', '91-2109876543', '808 H-Block, Bais Godam, Jaipur, 302006')
INTO Customers (customer_id, name, email, phone, address) VALUES (19, 'Pooja Joshi',
'[email protected]', '91-1098765432', '909 I-Block, Navrangpura, Ahmedabad, 380009')
INTO Customers (customer_id, name, email, phone, address) VALUES (20, 'Rajesh Bhatia',
'[email protected]', '91-0987654321', '100 J-Block, Adajan, Surat, 395009')
SELECT * FROM dual;

2. Insert Restaurants
INSERT ALL
INTO Restaurants (restaurant_id, name, location, contact) VALUES (1, 'Biryani Paradise',
'Paharganj, New Delhi', '91-9876543210')
INTO Restaurants (restaurant_id, name, location, contact) VALUES (2, 'Tandoori Nights',
'Sector 17, Chandigarh', '91-8765432109')
INTO Restaurants (restaurant_id, name, location, contact) VALUES (3, 'Curry House',
'Jayanagar, Bangalore', '91-7654321098')
INTO Restaurants (restaurant_id, name, location, contact) VALUES (4, 'Spice Route',
'Connaught Place, New Delhi', '91-6543210987')
INTO Restaurants (restaurant_id, name, location, contact) VALUES (5, 'Punjabi Tadka', 'Hauz
Khas, New Delhi', '91-5432109876')
INTO Restaurants (restaurant_id, name, location, contact) VALUES (6, 'Saffron Spice',
'Colaba, Mumbai', '91-4321098765')

26
INTO Restaurants (restaurant_id, name, location, contact) VALUES (7, 'Dosa King',
'Koramangala, Bangalore', '91-3210987654')
INTO Restaurants (restaurant_id, name, location, contact) VALUES (8, 'Rasam Ruchi',
'Madhapur, Hyderabad', '91-2109876543')
INTO Restaurants (restaurant_id, name, location, contact) VALUES (9, 'Gulab Jamun Corner',
'Malleswaram, Bangalore', '91-1098765432')
INTO Restaurants (restaurant_id, name, location, contact) VALUES (10, 'Chaat Street',
'Andheri, Mumbai', '91-0987654321')
SELECT * FROM dual;

3. Insert Food Items


INSERT ALL
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (1, 1,
'Biryani', 'Aromatic rice dish ', 199.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (2, 1,
'Paneer Tikka', 'Grilled cottage cheese marinated in spices', 149.00, 'Appetizer')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (3, 2,
'Tandoori Chicken', 'Chicken marinated in yogurt and spices, grilled', 249.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (4, 2,
'French Fries', 'Crispy fried potato strips', 99.00, 'Appetizer')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (5, 3,
'Margherita Pizza', 'Classic pizza with cheese and basil', 299.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (6, 3,
'Butter Chicken', 'Chicken in creamy tomato sauce', 249.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (7, 4,
'Spaghetti Aglio e Olio', 'Pasta with garlic ', 199.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (8, 4,
'Chaat Platter', 'Assorted Indian street food snacks', 149.00, 'Appetizer')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (9, 5,
'Cheeseburger', 'Juicy beef burger with cheese ', 299.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (10,
5, 'Dahi Puri', 'Crispy puris filled with yogurt ', 99.00, 'Appetizer')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (11,
6, 'Masala Dosa', 'Crispy rice crepe filled with spiced potatoes', 149.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (12,
6, 'Caesar Salad', 'Salad with romaine lettuce, croutons ', 199.00, 'Appetizer')

27
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (13,
7, 'Grilled Fish', 'Fish fillet marinated and grilled to perfection', 299.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (14,
7, 'Samosa', 'Crispy pastry filled with spiced potatoes', 99.00, 'Appetizer')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (15,
8, 'Pasta Primavera', 'Pasta with seasonal vegetables in a light sauce', 199.00, 'Main Course')
INTO Food_Items (food_id, restaurant_id, name, description, price, category) VALUES (16,
8, 'Aloo Tikki', 'Spiced potato patties served with chutney', 99.00, 'Appetizer')
SELECT * FROM dual;

4. Insert Orders
INSERT ALL
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (1, 11, 1,
598.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (2, 12, 2,
299.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (3, 11, 3,
499.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (4, 12, 4,
249.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (5, 13, 5,
399.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (6, 14, 6,
199.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (7, 15, 7,
499.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (8, 16, 8,
399.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (9, 17, 1,
250.00, 'pending')
INTO Orders (order_id, customer_id, restaurant_id, total_amount, status) VALUES (10, 18, 2,
599.00, 'pending')
SELECT * FROM dual;

28
5. Insert Order Items
INSERT ALL
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (1, 1, 2, 398.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (1, 2, 1, 149.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (2, 3, 1, 249.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (2, 4, 1, 99.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (3, 5, 1, 299.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (3, 6, 1, 199.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (4, 7, 1, 199.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (4, 8, 1, 149.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (5, 9, 1, 299.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (5, 10, 1, 99.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (6, 11, 1, 149.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (6, 12, 1, 199.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (7, 13, 1, 299.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (7, 14, 1, 99.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (8, 15, 1, 199.00)
INTO Order_Items (order_id, food_id, quantity, subtotal) VALUES (8, 16, 1, 99.00)
SELECT * FROM dual;

6. Insert Billing

INSERT ALL
INTO Billing (billing_id, order_id, billing_date, payment_method, total_amount) VALUES (1,
1, CURRENT_TIMESTAMP, 'Credit Card', 598.00)
INTO Billing (billing_id, order_id, billing_date, payment_method, total_amount) VALUES (2,
2, CURRENT_TIMESTAMP, 'Cash', 299.00)
INTO Billing (billing_id, order_id, billing_date, payment_method, total_amount) VALUES (3,
3, CURRENT_TIMESTAMP, 'Debit Card', 499.00)
INTO Billing (billing_id, order_id, billing_date, payment_method, total_amount) VALUES (4,
4, CURRENT_TIMESTAMP, 'UPI', 249.00)

29
INTO Billing (billing_id, order_id, billing_date, payment_method, total_amount) VALUES (5,
5, CURRENT_TIMESTAMP, 'Credit Card', 399.00)
INTO Billing (billing_id, order_id, billing_date, payment_method, total_amount) VALUES (6,
6, CURRENT_TIMESTAMP, 'Cash', 199.00)
INTO Billing (billing_id, order_id, billing_date, payment_method, total_amount) VALUES (7,
7, CURRENT_TIMESTAMP, 'Debit Card', 499.00)
INTO Billing (billing_id, order_id, billing_date, payment_method, total_amount) VALUES (8,
8, CURRENT_TIMESTAMP, 'Cash', 399.00)
SELECT * FROM dual;

SELECT * FROM Customers;


SELECT * FROM Restaurants;
SELECT * FROM Food_Items;
SELECT * FROM Orders;

CODE FOR DISPLAY

CODE OF DISPLAYING PAYMENT SUCCESSFUL

DECLARE
v_order_id INT := 1; -- Set this to the order you want to check
v_payment_count INT;
BEGIN
-- Check if the payment has been made for the given order_id
SELECT COUNT(*) INTO v_payment_count
FROM Billing
WHERE order_id = v_order_id;

IF v_payment_count > 0 THEN


-- Payment has been made
DBMS_OUTPUT.PUT_LINE('Payment successful! Thank you for your visit.');
ELSE

30
DBMS_OUTPUT.PUT_LINE('Please pay your bill.');
END IF;
END;
/

DECLARE
v_order_id Orders.order_id%TYPE;
v_customer_name Customers.name%TYPE;
v_restaurant_name Restaurants.name%TYPE;
v_order_date Orders.order_date%TYPE;
v_food_id Food_Items.food_id%TYPE;
v_food_name Food_Items.name%TYPE;
v_quantity Order_Items.quantity%TYPE;
v_subtotal Order_Items.subtotal%TYPE;
v_order_total Orders.total_amount%TYPE;
v_billing_date Billing.billing_date%TYPE;
v_payment_method Billing.payment_method%TYPE;
v_billing_total Billing.total_amount%TYPE;
v_status Orders.status%TYPE;

BEGIN
v_order_id := 1;
v_customer_name := 'John Doe';
v_restaurant_name := 'Pasta Place';
v_order_date := SYSDATE;
v_food_id := 101;
v_food_name := 'Spaghetti';
v_quantity := 2;
v_subtotal := 20.00;
v_order_total := 50.00;

31
v_billing_date := SYSDATE;
v_payment_method := 'Credit Card';
v_billing_total := 50.00;
v_status := 'Completed';

DBMS_OUTPUT.PUT_LINE('-----------------------------------');
DBMS_OUTPUT.PUT_LINE('Order ID: ' || v_order_id);
DBMS_OUTPUT.PUT_LINE('Customer: ' || v_customer_name);
DBMS_OUTPUT.PUT_LINE('Restaurant: ' || v_restaurant_name);
DBMS_OUTPUT.PUT_LINE('Order Date: ' || v_order_date);
DBMS_OUTPUT.PUT_LINE('Food Item: ' || v_food_name);
DBMS_OUTPUT.PUT_LINE('Quantity: ' || v_quantity);
DBMS_OUTPUT.PUT_LINE('Subtotal: ' || v_subtotal);
DBMS_OUTPUT.PUT_LINE('Order Total: ' || v_order_total);
DBMS_OUTPUT.PUT_LINE('Billing Date: ' || v_billing_date);
DBMS_OUTPUT.PUT_LINE('Payment Method: ' || v_payment_method);
DBMS_OUTPUT.PUT_LINE('Billing Total: ' || v_billing_total);
DBMS_OUTPUT.PUT_LINE('Status: ' || v_status);
DBMS_OUTPUT.PUT_LINE('-----------------------------------');
END;

32
SQL COMMANDS FOR DML OPERATIONS ON TABLE
• INSERT Statement:
INSERT INTO Restaurants (restaurant_id, name, location,
contact)
VALUES (1, 'Pizza Place', '123 Main St', '555-1234');
• UPDATE Statement:
UPDATE Customers
SET phone = '555-9999'
WHERE customer_id = 1;
• DELETE Statement:
DELETE FROM Orders
WHERE order_id = 1;

SELECT Statement (Various examples):


• Selecting Specific Column:
SELECT name
FROM Restaurants;
• Arithmetic Operation:
SELECT price, price * 1.1 AS increased_price
FROM Food_Items;
• Using the WHERE Clause:
SELECT *
FROM Customers
WHERE address LIKE '%St%';
• Using Aggregate Functions (e.g., COUNT, AVG,
etc.):
SELECT COUNT(*), AVG(total_amount),
SUM(total_amount), MAX(total_amount)
FROM Orders;

33
• Using GROUP BY Clause:
SELECT restaurant_id, COUNT(*)
FROM Food_Items
GROUP BY restaurant_id;
• Using HAVING Clause:
SELECT restaurant_id, COUNT(*)
FROM Food_Items
GROUP BY restaurant_id
HAVING COUNT(*) > 2;
• Subquery Example (Using IN):
SELECT name
FROM Restaurants
WHERE restaurant_id IN (SELECT restaurant_id
FROM Orders
WHERE total_amount > 50);
• Using JOIN (Equi-Join):
SELECT c.name AS customer_name, o.order_id
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id;
• Set Operators - UNION:
SELECT name FROM Customers
UNION
SELECT name FROM Restaurants;

34
SQL COMMANDS FOR PL-SQL OPERATIONS ON
TABLE

1. PL/SQL Procedure:
Create a Procedure to Add a New Order:
CREATE PROCEDURE Add_New_Order(p_customer_id
NUMBER(9), p_restaurant_id NUMBER(9), p_total_amount
NUMBER(9)) AS
BEGIN
INSERT INTO Orders (customer_id, restaurant_id,
total_amount)
VALUES (p_customer_id, p_restaurant_id, p_total_amount);
COMMIT;
END;
Calling Add_New_Order Procedure:
BEGIN
Add_New_Order(p_customer_id => 1001, p_restaurant_id =>
200, p_total_amount => 1500);
END;
Output:
SELECT * FROM Orders WHERE customer_id = 101;
Sample Output:
ORDER_ID | CUSTOMER_ID | RESTAURANT_ID TOTAL_AMOUNT ORDER_DATE

1001 | 101 | 1 | 5000 | 2024-11-09

2.Create a Procedure to Update Food Item Price:

35
CREATE PROCEDURE Update_Food_Item_Price(p_food_id
NUMBER(9), p_new_price NUMBER(9)) AS
BEGIN
UPDATE Food_Items
SET price = p_new_price
WHERE food_id = p_food_id;
COMMIT;
END;
• Calling the Procedure to Update Food Item Price
Procedure Code:
BEGIN
Update_Food_Item_Price(p_food_id => 101, p_new_price =>
250);
END;
Output:
SELECT food_id, price FROM Food_Items WHERE food_id =
101;
Sample Output:
FOOD_ID | PRICE
101 | 799

2. PL/SQL Function:
1.Create a Function to Get the Price of a Food Item:
CREATE FUNCTION Get_Food_Item_Price(p_food_id
NUMBER(9)) RETURN NUMBER AS
v_price NUMBER(9);
BEGIN

36
SELECT price INTO v_price
FROM Food_Items
WHERE food_id = p_food_id;
RETURN v_price;
END;

Sample Output:
GET_FOOD_ITEM_PRICE(101)

799

2.Create a Function to Count the Number of


Customers:
CREATE OR REPLACE FUNCTION Count_Customers
RETURN INT AS
v_count INT;
BEGIN
SELECT COUNT(*) INTO v_count
FROM Customers;
RETURN v_count;
END;
• Calling the Function to Count the Number of Customers
Function Call:
SELECT Count_Customers FROM DUAL;
Sample Output:
COUNT_CUSTOMERS()

500

37
3. PL/SQL Trigger:
1.Create a Trigger Before Inserting a Food Item to
Validate Price:

CREATE OR REPLACE TRIGGER trg_before_insert_food


BEFORE INSERT ON Food_Items
FOR EACH ROW
BEGIN
IF :NEW.price < 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Price must be
positive.');
END IF;
END;
Trigger Output (Before Insert on Food_Items)
Output:
Error report:
SQL Error: ORA-20001: Price must be positive.
ORA-06512: at "SYSTEM.TRG_BEFORE_INSERT_FOOD",
line 4
ORA-04088: error during execution of trigger
'SYSTEM.TRG_BEFORE_INSERT_FOOD'

4. PL/SQL Sequence:
1.Create a Sequence for Generating Restaurant IDs:
CREATE SEQUENCE restaurant_seq
START WITH 1
INCREMENT BY 1;
38
Using Sequence to Generate Restaurant ID
Sample Output (Assuming this is the first insert):
RESTAURANT_ID | NAME | LOCATION | CONTACT

1 | New Restaurant | New Location | 91-0000000000

5. PL/SQL Exception:
1.Use Built-in Exception (e.g., Handling No Data Found):
BEGIN
SELECT *
FROM Food_Items
WHERE food_id = -1;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No food item found.');
END;
Handling Built-in Exception (No Data Found)
Output:
No food item found.

2.Use User-Defined Exception (e.g., Handling Null Price):


DECLARE
e_no_price EXCEPTION;
v_price DECIMAL(10, 2);
BEGIN
SELECT price INTO v_price
FROM Food_Items
WHERE food_id = 1;
IF v_price IS NULL THEN
RAISE e_no_price;
39
END IF;
EXCEPTION
WHEN e_no_price THEN
DBMS_OUTPUT.PUT_LINE('Price is NULL.');
END;
Handling User-Defined Exception (Null Price)
Output:
Price is NULL.

Summary of oracle output:


1. Procedure:
o Add_New_Order – Adds a new order.
o Update_Food_Item_Price – Updates food item price.
2. Function:
o Get_Food_Item_Price – Returns the price of a food item.
o Count_Customers – Returns the count of customers.
3. Trigger:
o trg_before_insert_food – Trigger to validate food item
price before insert.
4. Sequence:
o restaurant_seq – Generates sequential IDs for restaurants.
5. Exception Handling:
o Built-in Exception: Handles NO_DATA_FOUND.
o User-Defined Exception: Handles NULL price for food
items.

40
Resources used
1.W3Schools
▪ SQL Tutorial: Offers interactive lessons on SQL with examples
and quizzes. A great resource for beginners.
• W3Schools SQL Tutorial
▪ PL/SQL Tutorial: While primarily focused on SQL, W3Schools
provides basic PL/SQL examples and explanations, which are
helpful for getting started.
• W3Schools PL/SQL Tutorial
2.Documentation & Official Resources:
• Oracle PL/SQL Documentation: Oracle Docs
• MySQL Docs: MySQL Documentation
• PostgreSQL Docs: PostgreSQL Documentation

41
❖ Simple Queries

1. List all the restaurant details:


SELECT *
FROM Restaurants;
2. List all food item details:
SELECT *
FROM Food_Items;
3. List all customer information:
SELECT *
FROM Customers;
4. List all order information:
SELECT *
FROM Orders;
5. List all order item details:
SELECT *
FROM Order_Items;
6. List all billing details:
SELECT *
FROM Billing;

❖ WHERE Clause

1.List all food items that are available: Assuming "available"


means food items that have prices.

42
SELECT *
FROM Food_Items
WHERE price > 0;
2.List customers who live in New York:
SELECT *
FROM Customers
WHERE address LIKE '%New York%';
3.List all orders placed after January 1, 2024:
SELECT *
FROM Orders
WHERE order_date > TO_DATE('2024-01-01', 'YYYY-MM-
DD');
4.List food items that are priced under ₹750:
SELECT *
FROM Food_Items
WHERE price < 750;
5.List customers who have placed orders in the last month:
SELECT DISTINCT c.*
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id
WHERE o.order_date > ADD_MONTHS(SYSDATE, -1);
6.List all orders with a total bill greater than ₹4,000:
SELECT *
FROM Orders
WHERE total_amount > 4000;

43
❖ ORDER BY Clause
1.List customer names in ascending order:
SELECT name
FROM Customers
ORDER BY name ASC;
2.List all food items ordered by price in descending order:
SELECT *
FROM Food_Items
ORDER BY price DESC;
3.List orders sorted by order date from latest to oldest:
SELECT *
FROM Orders
ORDER BY order_date DESC;
4.List billing records sorted by billing date:
SELECT *
FROM Billing
ORDER BY billing_date;
5.List customers sorted by registration date: Assuming
registration date is the first order date, or you have a column for
registration:
SELECT *
FROM Customers
ORDER BY customer_id;
6.List food items sorted by name in ascending order:
SELECT *
FROM Food_Items
ORDER BY name ASC;

❖ GROUP BY Clause

44
1.List the number of orders placed by each customer:
SELECT customer_id, COUNT(*) AS num_orders
FROM Orders
GROUP BY customer_id;
2.List the total sales amount for each food item:
SELECT fi.food_id, fi.name, SUM(oi.quantity * oi.subtotal) AS
total_sales
FROM Food_Items fi
JOIN Order_Items oi ON fi.food_id = oi.food_id
GROUP BY fi.food_id, fi.name;
3.List the average bill amount for each customer:
SELECT customer_id, AVG(total_amount) AS avg_bill
FROM Orders
GROUP BY customer_id;
4.List the number of food items ordered in each order:
SELECT order_id, SUM(quantity) AS total_items_ordered
FROM Order_Items
GROUP BY order_id;
5.List the total number of food items grouped by category:
SELECT category, SUM(quantity) AS total_items
FROM Order_Items oi
JOIN Food_Items fi ON oi.food_id = fi.food_id
GROUP BY category;

❖ HAVING Clause
1.List customers with more than 5 orders:
SELECT customer_id, COUNT(*) AS num_orders
FROM Orders
GROUP BY customer_id

45
HAVING COUNT(*) > 5;
2.List food items with total sales greater than ₹80,000:
SELECT fi.food_id, fi.name, SUM(oi.quantity * oi.subtotal) AS
total_sales
FROM Food_Items fi
JOIN Order_Items oi ON fi.food_id = oi.food_id
GROUP BY fi.food_id, fi.name
HAVING SUM(oi.quantity * oi.subtotal) > 80000;
3.List categories where the average price exceeds ₹1,500:
SELECT category, AVG(price) AS avg_price
FROM Food_Items
GROUP BY category
HAVING AVG(price) > 1500;
4.List orders with a total bill greater than ₹15,000:
SELECT * FROM Orders
HAVING total_amount > 15000;
5.List cities with more than 50 customers:
SELECT SUBSTRING(address, INSTR(address, ',') + 1) AS
city, COUNT(*) AS num_customers
FROM Customers
GROUP BY SUBSTRING(address, INSTR(address, ',') + 1)
HAVING COUNT(*) > 50;
6.List food categories where the total quantity sold is greater
than 100:
SELECT fi.category, SUM(oi.quantity) AS total_quantity
FROM Order_Items oi
JOIN Food_Items fi ON oi.food_id = fi.food_id
GROUP BY fi.category
HAVING SUM(oi.quantity) > 100;

46
❖ JOINS
1.List all orders along with customer names:
SELECT o.order_id, c.name AS customer_name,
o.total_amount
FROM Orders o
JOIN Customers c ON o.customer_id = c.customer_id;
2.List all order items with corresponding food item names:
SELECT oi.order_item_id, fi.name AS food_item, oi.quantity,
oi.subtotal
FROM Order_Items oi
JOIN Food_Items fi ON oi.food_id = fi.food_id;
3.List billing records along with order details:
SELECT b.billing_id, o.order_id, b.billing_date,
b.payment_method, b.total_amount
FROM Billing b
JOIN Orders o ON b.order_id = o.order_id;
4.List customers with their order details:
SELECT c.name AS customer_name, o.order_id,
o.total_amount
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id;
5.List food items and their categories:
SELECT fi.name AS food_item, fi.category
FROM Food_Items fi;
6.List suppliers and the food items they supply:
(Assuming there is a "Suppliers" table linked with
"Food_Items".)
SELECT s.supplier_name, fi.name AS food_item
FROM Suppliers s
JOIN Food_Items fi ON s.supplier_id = fi.supplier_id;

47
❖ Set Operations
1.List all food items that are available and all discontinued food
items:
SELECT name
FROM Food_Items
WHERE status = 'Available'
UNION
SELECT name
FROM Food_Items
WHERE status = 'Discontinued';
2.List all customers who have placed orders combined with
those who have not:
SELECT customer_id
FROM Orders
UNION
SELECT customer_id
FROM Customers;
2.List all customer IDs in orders and billing records:
SELECT customer_id
FROM Orders
UNION
SELECT customer_id
FROM Billing;
3.List all unique food item names from current food items and
seasonal specials:
SELECT name
FROM Food_Items
WHERE status = 'Current'
UNION
SELECT name
48
FROM Food_Items
WHERE status = 'Seasonal';
4.List all customer emails from the current customer table and
the archived customer table:
SELECT email
FROM Customers
UNION
SELECT email
FROM Archived_Customers;
5.List all food item IDs from vegetarian and non-vegetarian
categories:
SELECT food_id
FROM Food_Items
WHERE category = 'Vegetarian'
UNION
SELECT food_id FROM Food_Items
WHERE category = 'Non-Vegetarian';

❖ Subqueries
1.List all customers who have placed orders with total amounts
greater than the average order amount:
SELECT * FROM Customers c
WHERE c.customer_id IN (
SELECT o.customer_id
FROM Orders o
WHERE o.total_amount > (SELECT AVG(total_amount)
FROM Orders));
2.List all food items that are priced above the average price in
their category:

49
SELECT * FROM Food_Items fi
WHERE fi.price > (
SELECT AVG(price)
FROM Food_Items
WHERE category = fi.category);
3.List orders placed by customers from California:
SELECT * FROM Orders o
WHERE o.customer_id IN (
SELECT c.customer_id
FROM Customers c
WHERE c.address LIKE '%California%');
4.List customers who have ordered food items from a specific
category:
SELECT DISTINCT c.*
FROM Customers c
JOIN Orders o ON c.customer_id = o.customer_id
JOIN Order_Items oi ON o.order_id = oi.order_id
JOIN Food_Items fi ON oi.food_id = fi.food_id
WHERE fi.category = 'Pizza';
5.List all food items that have been ordered more than the
average quantity:
SELECT fi.name, SUM(oi.quantity) AS total_quantity
FROM Food_Items fi
JOIN Order_Items oi ON fi.food_id = oi.food_id
GROUP BY fi.food_id, fi.name
HAVING SUM(oi.quantity) > (SELECT AVG(quantity)
FROM Order_Items);
6.List all customers who have made orders greater than
₹40,000:
SELECT c.*
FROM Customers c
50
WHERE c.customer_id IN (
SELECT o.customer_id
FROM Orders o
WHERE o.total_amount > 40000
);

51
Conclusion
The Restaurant Management System is a web-based
platform designed to streamline restaurant operations such as
order management, billing, employee scheduling, and
inventory control. By automating these processes, the system
helps restaurant managers make data-driven decisions and
optimize resources efficiently. The system also ensures
secure data handling and provides a user-friendly experience
for both staff and customers, making it an effective
replacement for traditional manual methods.
Learning Outcomes:
▪ We learned how to Design the database for a
restaurant management system by using an Entity-
Relationship (ER) diagram and normalizing it to 1NF,
2NF, and 3NF.
▪ We learned the concept of Database Management
Systems (DBMS), including its types, components, and
the role of DBMS in managing large datasets and
ensuring data integrity, security, and consistency.
▪ We understood how to Manage the database using
SQL by performing various operations like creating
tables, inserting data, and using queries to retrieve and
update information efficiently.
▪ We learned how to Implement PL/SQL code for the
restaurant application, including logic for handling
order processing, billing, and payment status updates,

52
demonstrating the ability to write stored procedures,
triggers, and functions.
▪ Applied security and backup methods on the
database to ensure that sensitive data is protected, users
have appropriate access levels, and the database is
regularly backed up for disaster recovery.
Applications:
1. Restaurant Operations: Automates daily tasks like
order taking and billing.
2. Customer Relationship Management (CRM):
Enhances customer service with personalized data.
3. Data Analytics: Helps managers make informed
decisions through reports and insights.
4. Third-Party Integrations: Supports integration with
payment and delivery systems.
5. Security: Ensures secure handling of sensitive data.

Reference:
www.google.com
www.chrome.com
www.food.com
www.zomato.com

53
54

You might also like