Database Project
Database Project
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
);
Update Data:
-- Update a bill's status to 'Paid'
UPDATE Bills SET Status = 'Paid' WHERE Bill_ID = 1;