Batch16 Project Report
Batch16 Project Report
A PROJECT REPORT
Submitted by
Student 1 [Reg No:RA221103011800]
BACHELOR OF TECHNOLOGY
in
COMPUTER SCIENCE AND ENGINEERING
BONAFIDE CERTIFICATE
by Abignael Joseph K.T, Magin K.S, Jayarama Das of II year/IV Sem B.Tech
Date: 03/05/24
The Grocery Store Management System (GSMS) represents a comprehensive software solution
aimed at optimizing the operations of a typical grocery store. Built upon modern technologies,
GSMS offers a suite of features encompassing product management, order processing, customer
engagement, and data analysis. At its core, GSMS empowers store owners and managers to
efficiently manage their inventory, process customer orders, and maintain a rich database of
customer information. Through intuitive interfaces and seamless workflows, GSMS enhances
operational efficiency and streamlines day-to-day tasks within the grocery store environment.Key
functionalities include product management, allowing for the addition, modification, and deletion
of products, ensuring accurate and up-to-date inventory records. Furthermore, GSMS facilitates
order processing, enabling swift and accurate order fulfillment while providing insights into sales
trends and customer preferences through robust reporting and analytics tools.The system also
prioritizes customer engagement, offering features for managing customer information, tracking
purchase history, and implementing loyalty programs. This fosters personalized interactions and
targeted marketing strategies, ultimately enhancing customer satisfaction and loyalty.
Technologically, GSMS leverages a modern stack, utilizing Python with Flask for backend
development, MySQL for database management, and HTML/CSS/JavaScript for frontend
interfaces.
TABLE OF CONTENTS
ABSTRACT
Problem Statement
For the Grocery Store Database Management System (GSDMS) project, understanding the
problem involves analyzing the requirements and objectives of managing inventory, sales, and
customer information within a grocery store. The identification of entities involves recognizing
key components such as products, customers, sales transactions, suppliers, and employees.
Relationships between these entities must be established to define how they interact within the
system.
Using an Entity-Relationship (ER) model, the following entities and relationships can be
constructed:
Entities:
1. Product: Represents items available for sale in the store.
2. Customer: Represents individuals who purchase products from the store.
3. Sale: Represents individual transactions where products are sold to customers.
4. Supplier: Represents companies or entities supplying products to the store.
5. Employee: Represents staff members working in the store.
Relationships:
1. Product-Sale: Many-to-many relationship indicating which products are sold in each
transaction.
2. Customer-Sale: One-to-many relationship representing customers making multiple purchases.
3. Supplier-Product: One-to-many relationship indicating which suppliers provide specific
products.
PROJECT.
To design the relational schemas and create the necessary database tables for the Grocery Store
Management System (GSMS) project, we need to consider the entities and their relationships.
Based on the provided Python code and its functionalities, here is a proposed design:
Entities:
1. Orders:
2. Order_Details:
3. Products:
UOM), price_per_unit
Design Considerations:
- Each order can have multiple order details, representing the products purchased in that order.
1. Orders Table:
sql
customer_name VARCHAR(255),
datetime DATETIME
);
2. Order_Details Table:
sql
order_id INT,
product_id INT,
quantity INT,
);
3. Products Table:
sql
product_name VARCHAR(255),
uom_id INT,
);
4. UOM Table:
sql
uom_name VARCHAR(50)
);
These SQL statements define the structure of the database tables needed to implement the GSMS
project. They establish relationships between entities using foreign keys to ensure data integrity
and enable efficient querying of the database. Adjustments can be made based on additional
1. Constraints:
- Unique Constraint: Ensure that no two orders have the same order number.
sql
- Check Constraint: Ensure that the total price in the Order_Details table is always positive.
sql
2. Sets:
- Union: Retrieve a list of all products along with their prices, including those with zero stock.
sql
UNION
3. Joins:
- Retrieve a list of orders along with their details (customer name, order date, product name,
quantity, total price).
sql
od.total_price
FROM Orders o
4. Views:
- Create a view to display the total sales amount for each product.
sql
FROM Order_Details
GROUP BY product_id;
5. Triggers:
- Create a trigger to automatically update the total price in the Orders table when new order
sql
BEGIN
UPDATE Orders
END;
6. *Cursors*:
- Use a cursor to iterate over all orders and calculate the total sales amount.
sql
OPEN cur;
read_loop: LOOP
IF done THEN
LEAVE read_loop;
END IF;
END LOOP;
IV. ANALYZING THE PITFALLS, IDENTIFYING THE DEPENDENCIES, AND
APPLYING NORMALIZATIONS
1. Analyzing Pitfalls:
- Data Redundancy: Redundant data can lead to inconsistencies and wasted storage space.
- Update Anomalies: Insertion, deletion, and modification of data may result in inconsistencies
or unintended consequences.
2. Identifying Dependencies:
through a non-primary key attribute. For instance, in Products table, price_per_unit may depend
on uom_id.
3. Applying Normalizations:
- First Normal Form (1NF): Ensure that each table has a primary key and atomic attributes. Split
- Second Normal Form (2NF): Remove partial dependencies by ensuring that non-key attributes
Orders Table:
Order_Details Table:
Products Table:
UOM Table:
- Attribute: uom_name
Normalization:
1. 1NF: All tables have a primary key, and attributes are atomic.
2. 2NF:
3. 3NF:
Dependencies:
By applying normalization, we've reduced redundancy, minimized update anomalies, and ensured
that dependencies are appropriately managed, resulting in a more robust and efficient database
MECHANISMS
Implementing concurrency control and recovery mechanisms is crucial for ensuring data
consistency and system reliability in a database management system like the Grocery Store
1. Concurrency Control:
- Use locks to control access to shared resources (e.g., database records) and prevent
conflicting operations.
- Implement two-phase locking (2PL) protocol to acquire locks before performing operations
python
import threading
# Global lock
lock = threading.Lock()
# Acquire lock
lock.acquire()
# Release lock
b. Timestamp-Based Concurrency Control:
- Assign timestamps to transactions to determine their relative order and resolve conflicts.
- Use techniques like Timestamp Ordering or Thomas' Write Rule for concurrency control.
python
import time
timestamp = time.time()
2. Recovery Mechanisms:
- Implement a logging mechanism where changes are first recorded in a log before being
- Ensure that log records are written to stable storage before corresponding data modifications.
python
- Periodically perform checkpoints to save the current state of the database to stable storage.
- Use checkpoints to reduce the time required for recovery after a crash.
python
def perform_checkpoint():
# ...
- Implement mechanisms to rollback transactions that have not been committed in case of
failures.
python
def rollback(transaction_id):
# ...
def commit(transaction_id):
python
def redo(log_record):
# ...
def undo(log_record):
By implementing these concurrency control and recovery mechanisms, you can ensure data
consistency and system reliability in the GSMS, even in the face of concurrent transactions and
system failures.
VI. CODE FOR THE PROJECT
def get_all_products(connection):
cursor = connection.cursor()
products.uom_id=uom.uom_id")
cursor.execute(query)
response = []
response.append({
'product_id': product_id,
'name': product_name,
'uom_id': uom_id,
'price_per_unit': price_per_unit,
'uom_name': uom_name
})
return response
cursor = connection.cursor()
cursor.execute(query,data)
connection.commit()
return cursor.lastrowid
# deletion of products
cursor = connection.cursor()
cursor.execute(query)
connection.commit()
return cursor.lastrowid
if _name=='main_':
connection = get_sql_connection()
## for insertion :
# print(insert_new_product(connection, {
# 'product_name': 'cabage',
# 'uom_id':'1',
# 'price_per_unit': '10'
# }))
# for deletion :
# print(delete_product(connection, 9))
import uom_dao
import mysql.connector
import json
import products_dao
import orders_dao
app = Flask(_name_)
connection = get_sql_connection()
@app.route('/getUOM', methods=['GET'])
def get_uom():
response = uom_dao.get_uoms(connection)
response = jsonify(response)
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/getProducts', methods=['GET'])
def get_products():
response = products_dao.get_all_products(connection)
response = jsonify(response)
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/insertProduct', methods=['POST'])
def insert_product():
request_payload = json.loads(request.form['data'])
response = jsonify({
'product_id': product_id
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/getAllOrders', methods=['GET'])
def get_all_orders():
response = orders_dao.get_all_orders(connection)
response = jsonify(response)
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/insertOrder', methods=['POST'])
def insert_order():
request_payload = json.loads(request.form['data'])
response = jsonify({
'order_id': order_id
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/deleteProduct', methods=['POST'])
def delete_product():
response = jsonify({
'product_id': return_id
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
if _name_ == "_main_":
app.run(port=5002) # if you get internal server error then you can change port number hrere
import datetime
import mysql.connector
__cnx = None
def get_sql_connection():
global __cnx
if __cnx is None:
auth_plugin='mysql_native_password')
return __cnx
def get_uoms(connection):
cursor = connection.cursor()
cursor.execute(query)
response = []
response.append({
'uom_id': uom_id,
'uom_name': uom_name
})
return response
if _name== 'main_':
connection = get_sql_connection()
print(get_uoms(connection))
[<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
scale=1.0">
<meta name="csrf-token"
content="kmapods5wQ5L1hn7rcR9OPst7EsN0gC7SrHh3m9K"/>
font/2.2.0/css/material-design-iconic-font.min.css">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:400,300,600,700">
<html>
<head>
<meta charset="utf-8">
scale=1.0">
font/2.2.0/css/material-design-iconic-font.min.css">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:400,300,600,700">
</head>
<body class="tooltips">
<div class="container">
</button>
<div class="container">
<ul class="breadcrumb">
<a href="index.html">
</a>
<a href="manage-product.html">
</a>
</ul>
</ul>
</div>
</div>
</div>
</div>
<h2>Manage Products</h2>
<div class="col-sm-12">
toggle="modal" data-target="#productModal">
</button>
</div>
</div>
<thead>
<th>Name</th>
<th>Unit</th>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<form id="productForm">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label >Name</label>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<label >Unit</label>
</select>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script src="js/packages/jquery.min.js"></script>
<script src="js/custom/common.js"></script>
<script src="js/custom/manage-product.js"></script>
<script src="js/packages/bootstrap.min.js"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes"/>
font/2.2.0/css/material-design-iconic-font.min.css">
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:400,300,600,700">
</head>
<body class="tooltips">
<div class="container">
</button>
<div class="container">
<a href="index.html">
data-placement="bottom" title="Dashboard"></i>
</a>
<a href="manage-product.html">
placement="bottom" title="Products"></i>
</a>
</ul>
</ul>
</div>
</div>
</div>
</div>
<form action="">
<h2>New Order
11px">
</h2>
<div class="col-sm-12">
<div class="col-sm-4">
<label >Product</label>
</div>
<div class="col-sm-3">
<label >Price</label>
</div>
<div class="col-sm-2">
<label >Quantity</label>
</div>
<div class="col-sm-3">
<label >Total</label>
</div>
</div>
</div>
</div>
<div class="product-box-extra" id="itemsInOrder">
</div>
<div>
<div class="row">
<div class="col-sm-12">
<span><b>Total</b></span>
</div>
<div class="col-sm-3">
id="saveOrder">Save</button>
</div>
</div>
</div>
</div>
</div>
</form>
<div class="col-sm-12">
<div class="col-sm-4">
width: 250px"></select>
</div>
<div class="col-sm-3">
value="0.0"></input>
</div>
<div class="col-sm-2">
</div>
<div class="col-sm-3">
total"></input><span> Rs</span>
Project Summary:
GSMS is a software solution designed to streamline grocery store operations. It offers features
for product, order, and customer management, aiming to enhance efficiency and customer
satisfaction.
Key Features:
Technologies Used:
Python with Flask for backend, MySQL for database, HTML/CSS/JavaScript for frontend.
Benefits:
Future Enhancements:
Integration with e-commerce platforms, mobile application development, predictive analytics,