0% found this document useful (0 votes)
5 views5 pages

Database Project

The Bill Management System is a relational database designed to manage user bills, payments, notifications, and recurring schedules through six key tables: User, Category, Bills, Notifications, Payment, and Recurring_Bills. It allows users to track their bills, receive notifications, and manage payments while providing functionalities for data insertion, updating, deletion, and selection. The system ensures secure access and organization of financial information for users.

Uploaded by

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

Database Project

The Bill Management System is a relational database designed to manage user bills, payments, notifications, and recurring schedules through six key tables: User, Category, Bills, Notifications, Payment, and Recurring_Bills. It allows users to track their bills, receive notifications, and manage payments while providing functionalities for data insertion, updating, deletion, and selection. The system ensures secure access and organization of financial information for users.

Uploaded by

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

Bill Management System

by
Harout Karakeshishian
Sako Andonian

Definition:
The Bill Management System is a relational database designed to efficiently manage
and organize user bills, payments, notifications, and recurring schedules. It
incorporates six key tables: User, Category, Bills, Notifications, Payment, and
Recurring_Bills, each playing a distinct role in the system.
• The User table stores essential user information such as name, email,
password, phone number, and address, ensuring proper identification and secure
access.
• The Category table categorizes bills into predefined types such as
electricity, water, and internet, helping users organize their expenses.
• The Bills table tracks details of each bill, including the user associated
with it, the category it belongs to, the amount, due date, status (Paid/Unpaid),
description, and optional attachment URLs for related documents.
• The Notifications table manages reminders and alerts for users, storing
notification types (e.g., reminders or overdue alerts) and dates, ensuring users
are informed about important bill-related activities.
• The Payment table captures details of payments made for bills, including
transaction IDs, payment methods, dates, and amounts, ensuring accurate financial
records.
• The Recurring_Bills table manages recurring bills, specifying the interval
(e.g., monthly) and the next due date, allowing users to automate payment
scheduling for recurring expenses.

2.ERD
3.Tables:
4. Relational Model

5.Table Creations:
-- User Table
CREATE TABLE User (
User_ID INT PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(100) NOT NULL,
Email VARCHAR(100) UNIQUE NOT NULL,
Password VARCHAR(255) NOT NULL,
Phone VARCHAR(15),
Address VARCHAR(255)
);

-- Category Table
CREATE TABLE Category (
Category_ID INT PRIMARY KEY AUTO_INCREMENT,
Category_Name VARCHAR(100) NOT NULL
);

-- Bills Table
CREATE TABLE Bills (
Bill_ID INT PRIMARY KEY AUTO_INCREMENT,
User_ID INT NOT NULL,
Category_ID INT NOT NULL,
Bill_Name VARCHAR(100) NOT NULL,
Amount DECIMAL(10, 2) NOT NULL,
Due_Date DATE NOT NULL,
Status VARCHAR(20) CHECK (Status IN ('Paid', 'Unpaid')),
Description TEXT,
Attachment_URL VARCHAR(255),
FOREIGN KEY (User_ID) REFERENCES User(User_ID) ON DELETE CASCADE,
FOREIGN KEY (Category_ID) REFERENCES Category(Category_ID) ON DELETE CASCADE
);

-- Notifications Table
CREATE TABLE Notifications (
Notification_ID INT PRIMARY KEY AUTO_INCREMENT,
User_ID INT NOT NULL,
Notification_Type VARCHAR(50) NOT NULL,
Notification_Date DATE NOT NULL,
FOREIGN KEY (User_ID) REFERENCES User(User_ID) ON DELETE CASCADE
);

-- Payment Table
CREATE TABLE Payment (
Payment_ID INT PRIMARY KEY AUTO_INCREMENT,
Bill_ID INT NOT NULL,
Transaction_ID VARCHAR(50) NOT NULL,
Payment_Method VARCHAR(50) NOT NULL,
Payment_Date DATE NOT NULL,
Amount DECIMAL(10, 2) NOT NULL,
FOREIGN KEY (Bill_ID) REFERENCES Bills(Bill_ID) ON DELETE CASCADE
);

-- Recurring Bills Table


CREATE TABLE Recurring_Bills (
Recurring_ID INT PRIMARY KEY AUTO_INCREMENT,
Bill_ID INT NOT NULL,
Interval VARCHAR(50) NOT NULL,
Next_Due_Date DATE NOT NULL,
FOREIGN KEY (Bill_ID) REFERENCES Bills(Bill_ID) ON DELETE CASCADE);
6.Data Manipulation:
Insert Data:
-- Insert data into User table
INSERT INTO User (Name, Email, Password, Phone, Address) VALUES ('Alice Smith',
'[email protected]', 'password123', '1234567890', '123 Elm Street'), ('Bob
Johnson', '[email protected]', 'securepass', '9876543210', '456 Oak Avenue');

-- Insert data into Category table


INSERT INTO Category (Category_Name) VALUES ('Electricity'),('Water'),
('Internet');

-- Insert data into Bills table


INSERT INTO Bills (User_ID, Category_ID, Bill_Name, Amount, Due_Date, Status,
Description, Attachment_URL) VALUES (1, 1, 'Electricity Bill Dec', 100.50, '2024-
12-30', 'Unpaid', 'Electricity bill for December', NULL), (2, 2, 'Water Bill Dec',
45.75, '2024-12-28', 'Unpaid', 'Water bill for December', NULL);

-- Insert data into Notifications table


INSERT INTO Notifications (User_ID, Notification_Type, Notification_Date) VALUES
(1, 'Reminder', '2024-12-25'),(2, 'Overdue Alert', '2024-12-27');

-- Insert data into Payment table


INSERT INTO Payment (Bill_ID, Transaction_ID, Payment_Method, Payment_Date, Amount)
VALUES (1, 'TX123456', 'Credit Card', '2024-12-27', 100.50);

-- Insert data into Recurring_Bills table


INSERT INTO Recurring_Bills (Bill_ID, Interval, Next_Due_Date) VALUES (1,
'Monthly', '2025-01-30');

Update Data:
-- Update a bill's status to 'Paid'
UPDATE Bills SET Status = 'Paid' WHERE Bill_ID = 1;

-- Update the next due date of a recurring bill


UPDATE Recurring_Bills SET Next_Due_Date = '2025-02-28' WHERE Recurring_ID = 1;
Delete Data from Tables:
DELETE FROM Notifications WHERE Notification_ID = 1;
DELETE FROM Bills WHERE Bill_ID = 2;

Select Data from Tables


1. List all unpaid bills for a specific user:
SELECT * FROM Bills WHERE User_ID = 1 AND Status = 'Unpaid';
2. Retrieve all payments made by a user:
SELECT Payment.*, Bills.Bill_Name FROM Payment JOIN Bills ON Payment.Bill_ID =
Bills.Bill_ID WHERE Bills.User_ID = 1;
3. Get all upcoming due bills:
SELECT Bills.Bill_Name, Bills.Due_Date, User.Name, User.Email FROM Bills JOIN User
ON Bills.User_ID = User.User_ID WHERE Bills.Due_Date > CURDATE() AND Bills.Status =
'Unpaid';
4. Generate a report of recurring bills and their next due dates:
SELECT Bills.Bill_Name, Recurring_Bills.Interval, Recurring_Bills.Next_Due_Date
FROM Recurring_Bills JOIN Bills ON Recurring_Bills.Bill_ID = Bills.Bill_ID;
5. Count the total number of payments made:
SELECT COUNT(*) AS TotalPayments FROM Payment;

You might also like