Dbms 01 Project
Dbms 01 Project
MICRO PROJECT
ON
SUBMITTED BY
[PROF. S.K.PATIL]
NASHIK GRAMIN SHIKSHAN PRASARK MANDAL’S
CERTIFICATE
Guide External
1 Abstract 1
4 Resource 4
5 Feature 5
7 Source Code 12
8 Output 15
9 Testing 17
3
Abstract
The Pharmacy Management System is a desktop-based application
developed to automate the day-to-day operations of a pharmacy,
ensuring efficient management of inventory, sales, and customer
records. This system is implemented using C++ for front-end
operations and MySQL as the back-end database for storing
and managing data.
4
Introduction
and billing, ensuring that the right medicine is available at the right
5
Project and Details:
Pharmacy & medicine Management System Project in C++ and MySQL Database
Programming Language
C++ Programming Language
Used:
IDE Tool
Codeblocks
(Recommended):
Action Plan
1. Research and understand the key features required for a Pharmacy
Management System.
2. Design a database in MySQL to manage data related to medicines,
suppliers, customers, and transactions.
3. Develop the front-end functionality in C++ for performing
CRUD operations (Create, Read, Update, Delete) with the MySQL
database.
4. Test the system to ensure it meets the requirements and
handles various edge cases.
Database and Table Name use in Pharmacy Management System
Project in C++ and MySQL Database
• Table Name: medicine_tb
• Database: pharmacy_c++_db
• Sever and Library Usage: XAMPP Server, MySql Headers, MySql Libs
6
Resources Required
7
Features of Pharmacy Management System
Project in C++ and MySQL
• Buy Medicine Module – In the Pharmacy Management System, this module is for the
customer. If a consumer wishes to buy medicine, the vendor may quickly construct a list of the
medications and a total bill. The console will display all of the medicines on the list. The seller has
the option of selecting multiple drugs. A simple “Select” query returns all of the drugs in the list.
Following the confirmation of ids, the overall number of medicines purchased will drop.
Also, make sure the database is up to date. In addition, indicate the entire quantity of medicine
purchased.
• Show Item List – In Pharmacy Management System, the “Select” query will retrieve all of
• Find Item from List Module – In Pharmacy Management System, a user can locate an item
from a list. The application can find all similar products using only a few characters from the
• Add Item Stock Module – This function allows the user to add additional medicines.
The “Insert” query is used to create new records in the database. The user can fill in all
of the medicine’s details. The information is then entered into the database.
• Update Stock Item – This is the function to utilize if the user wants to update any information
about an item in the list. The “Update” query is used to make changes to the database.
By typing the simple term “xN,” the user can keep the old data in the database, and the
• Delete Stock Item – Any object in the database can be deleted by the user. The “Erase”
query is used to delete data. Simply type the item’s id and a notice will appear, indicating that
8
ER DIAGRAM FOR PHARMACY MANAGEMENT SYSTEM
9
TABLE CREATED IN MySQL :
Pharmacy Management System Project in C++ and MySQL Database Menu Module
Pharmacy Management System Project in C++ and MySQL Database Buy Medicine Module
Pharmacy Management System Project in C++ and MySQL Database Show Item List
10
Pharmacy Management System Project in C++ and MySQL Database Find Item from the List
Pharmacy Management System Project in C++ and MySQL Database Add Item in Stock
11
Pharmacy Management System Project in C++ and MySQL Database Update Stock Item
Pharmacy Management System Project in C++ and MySQL Database Delete Stock Item
12
SOURCE CODE :
#include <iostream>
#include <mysql/mysql.h>
using namespace std;
class PharmacyManagementSystem {
private:
MYSQL *conn;
MYSQL_ROW row;
MYSQL_RES *res;
public:
PharmacyManagementSystem() {
conn = mysql_init(0);
if (conn) {
cout << "Database connection initialized successfully." << endl;
} else {
cout << "Database initialization failed!" << endl;
}
conn = mysql_real_connect(conn, "localhost", "root", "password", "PharmacyDB", 3306, NULL, 0);
if (conn) {
cout << "Connected to MySQL Database!" << endl;
} else {
cout << "Failed to connect to MySQL Database!" << endl;
}
}
void displayMedicines() {
string query = "SELECT * FROM Medicines";
const char *q = query.c_str();
if (!mysql_query(conn, q)) {
res = mysql_store_result(conn);
while (row = mysql_fetch_row(res)) {
cout << "ID: " << row[0] << " | Name: " << row[1] << " | Price: " << row[2] << " | Quantity: " << row[3] <<
endl;
}
} else {
cout << "Failed to fetch data: " << mysql_error(conn) << endl;
}
}
13
void updateMedicine(int id, string name, double price, int quantity) {
string query = "UPDATE Medicines SET name='" + name + "', price=" + to_string(price) + ", quantity=" +
to_string(quantity) + " WHERE id=" + to_string(id);
const char *q = query.c_str();
if (!mysql_query(conn, q)) {
cout << "Medicine updated successfully!" << endl;
} else {
cout << "Failed to update medicine: " << mysql_error(conn) << endl;
}
}
~PharmacyManagementSystem() {
mysql_close(conn);
cout << "Database connection closed." << endl;
}
};
int main() {
PharmacyManagementSystem pms;
int choice;
do {
cout << "\nPharmacy Management System\n";
cout << "1. Add Medicine\n2. Display Medicines\n3. Update Medicine\n4. Delete Medicine\n5. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: {
string name;
double price;
int quantity;
cout << "Enter Medicine Name: ";
ci n >> name;
cout << "Enter Price: ";
cin >> price;
cout << "Enter Quantity: ";
cin >> quantity;
pms.addMedicine(name, price, quantity);
break;
}
case 2:
pms.displayMedicines();
14
break;
case 3: {
int id;
string name;
double price;
int quantity;
cout << "Enter Medicine ID to Update: ";
cin >> id;
cout << "Enter New Name: ";
cin >> name;
cout << "Enter New Price: ";
cin >> price;
cout << "Enter New Quantity: ";
cin >> quantity;
pms.updateMedicine(id, name, price, quantity);
break;
}
case 4: {
int id;
cout << "Enter Medicine ID to Delete: ";
cin >> id;
pms.deleteMedicine(id);
break;
}
case 5:
cout << "Exiting..." << endl;
break;
default:
cout << "Invalid choice!" << endl;
}
} while (choice != 5);
return 0;
}
15
OUTPUT:
Database connection initialized successfully.
Connected to MySQL Database!
16
Enter your choice: 3
Enter Medicine ID to Update: 1
Enter New Name: Aspirin Extra Strength
Enter New Price: 13.99
Enter New Quantity: 150
Medicine updated successfully!
17
Testing:
• Test Cases
Functionality Tests:
• Add Medicine:
o Test adding a valid medicine (e.g., "Aspirin", 12.99, 100).
o Test adding a medicine with invalid data (e.g., negative price or quantity).
• Display Medicines:
o Test displaying medicines when the database is empty.
o Test displaying medicines after adding a few entries.
• Update Medicine:
o Test updating an existing medicine's details.
o Test updating a non-existent medicine ID.
• Delete Medicine:
o Test deleting an existing medicine.
o Test deleting a non-existent medicine ID.
Usability Tests:
• Ensure user prompts are clear and informative.
• Verify that all menu options work as expected.
• Performance Testing
• Measure response time for each operation (adding, displaying, updating, and
deleting medicine
Hardware Requirements:
• Minimum Requirements:
o CPU: Intel i3 or equivalent
o RAM: 4 GB
o Storage: 100 MB free disk space
o Network: Internet connection (for MySQL server)
• Recommended Requirements:
o CPU: Intel i5 or equivalent
o RAM: 8 GB or more
o Storage: 500 MB free disk space
o Network: Stable internet connection for remote databases
Software Requirements:
• Operating System:
o Windows 10 or later / Ubuntu 20.04 or later
• Development Tools:
o C++ Compiler (e.g., GCC, MinGW for Windows)
o MySQL Server (e.g., MySQL Community Server)
o MySQL Connector/C++ (for database connectivity)
o IDE (e.g., Code::Blocks, Visual Studio, or any text editor)
• Database Management:
o MySQL Workbench (optional, for managing the database visually)
18
Bibliography:
1. Books:
o "C++ Primer" by Stanley B. Lippman, Josée Lajoie, and Barbara E. Moo
o "MySQL Cookbook" by Paul DuBois
o Database management system
2. Online Resources:
o MySQL Documentation: https://dev.mysql.com/doc/
o C++ Reference: https://en.cppreference.com/
o TutorialsPoint C++ Tutorial:
https://www.tutorialspoint.com/cplusplus/index.htm
3. Articles:
o "Secure Coding in C++: Best Practices" from various security blogs.
o MySQL Connector/C++ documentation on prepared statements
for security.
Conclusion:
19
Annexure – IV
(A) Process and Product Assessment (Convert above total marks out of 6 Marks)
Relevance to the
1
course
Literature Review/
2 Information
Collection
Completion of the
3 Target as per Project
Proposal
Analysis of Data and
4
Representation
Quality of
5
Prototype/Model
6 Report Preparation
(B) Individual Presentation/Viva (Convert above total marks out of 4 Marks)
7 Presentation
8 Viva
20
(6 Marks)
Dated Signature:
21
Annexure – IV
(A) Process and Product Assessment (Convert above total marks out of 6 Marks)
Relevance to the
1
course
Literature Review/
2 Information
Collection
Completion of the
3 Target as per Project
Proposal
Analysis of Data and
4
Representation
Quality of
5
Prototype/Model
6 Report Preparation
(B) Individual Presentation/Viva (Convert above total marks out of 4 Marks)
7 Presentation
8 Viva
22
Assessment
(4 Marks) (10 Marks)
(6 Marks)
Dated Signature:
23
Annexure - IV
(A) Process and Product Assessment (Convert above total marks out of 6 Marks)
Relevance to the
1
course
Literature Review/
2 Information
Collection
Completion of the
3 Target as per Project
Proposal
Analysis of Data and
4
Representation
Quality of
5
Prototype/Model
6 Report Preparation
(B) Individual Presentation/Viva (Convert above total marks out of 4 Marks)
7 Presentation
8 Viva
24
(A) Process and Product
(B) Individual Presentation/Viva Total Marks
Assessment
(4 Marks) (10 Marks)
(6 Marks)
Dated Signature:
25