“Water Bottle Tracker”
(For Water Refilling Stations)
In Partial fulfilment of the requirements in
IT 224L: Database Management Systems 1
Presented by:
NEPTHALIE A. DIONELA JR.
2nd
Presented to:
PROF. MARTZEL BASTE
April 2017
Background of the Study
Water Refilling Stations are very common in the Philippines this a small
but very profitable business. This business is very light and easy to manage
but there is this one big problem that all water refilling station owner face. The
issue of lost bottles, this problem is very common to all owners because they
can't track who borrowed it and where will it go.
According to my uncle who has that kind of business it is hard to trace
where the bottle go especially when you have many bottle supply and no
records who borrowed it where will it go.
Statement of Goals and Objectives
This project is entitled Water Bottle Tracker. The said project is a
database management system to be used to record the transactions of the
business. The main goal of this project is to is to make the water refilling
station owner free from the problem of lost bottles and for them to track where
the bottle go. The system will ask for the bottle number, name of the
customer, the date and time it was released and the address of the borrower.
The data’s will be automatically stored to a file and will be deleted once the
bottle is returned.
The study specifically aims to:
• Create an automated recording system which will be used to record the
time and date when the bottle is borrowed, name and address of who
borrowed the bottle.
• Record the sales history of the business from the beginning of time.
• Provide a customer management, a new customer will be given a
customer id which will be use in his or her future transactions.
• Provide a bottle management to know how many bottles are borrowed
or available.
Chapter II
Data Collection and Analysis
Business Rule
New customers will be registered. Its personal information will be
recorded and the customer will be given an ID number to be use for
future transactions. Customer will borrow bottle using its ID number,
the customer can borrow one or more bottles. The date and time will be
recorded and customer who borrowed it. The customer will return the
bottles (End of transaction). The purpose of this project is just to trace
who has the unreturned bottles so the management can collect it
easily.
Data Model
This figure below is an enterprise data model of the company showing
the logical relationship of each entity:
Chapter III Database Design
ERD Class Diagram or Crow’s foot Model
Data Dictionary
tbl_Borrowing
Nul
Column Type Default Links to
l
tbl_CustomerManagem
cm_Id int(11) Yes NULL
ent -> cm_Id
tbl_BottleManagement
bm_Id int(11) Yes NULL
-> bm_Id
DateBorrow datetim CURRENT_TIMESTA
No
ed e MP
tbl_BottleManagement
Nul Link Comment MIM
Column Type Default
l s to s E
bm_Id (Primar
int(11) No
y)
varchar(1
bm_Status No Active
0)
CURRENT_TIMESTA
bm_DateAdded datetime No
MP
tbl_CustomerManagement
Links
Column Type Null Default Comments MIME
to
cm_Id (Primary) int(11) No
cm_LastName varchar(30) No
cm_FirstName varchar(30) No
cm_MiddleName varchar(30) No
cm_address varchar(100) No
cm_ContactNo varchar(11) No
onsalebottles
Table comments: VIEW
Nul Link Comment MIM
Column Type Default
l s to s E
cm_Id int(11) No 0
cm_LastName varchar(30) No
varchar(100
cm_address No
)
cm_ContactNo varchar(11) No
Borrowed_Bottle
int(11) Yes NULL
s
0000-00-00
DateBorrowed datetime No
[Link]
Chapter IV
Physical Model (DDL)
tbl_BottleMangement table:
tbl_CustomerManagement table:
tbl_Borrowing table:
Chapter V
SQL – DML Statements
Creating table tbl_CustomerManagement:
create table tbl_CustomerManagement(cm_Id int primary key auto_increment, cm_LastName
varchar(30) not null, cm_FirstName varchar(30) not null, cm_MiddleName varchar(30) not null,
cm_address varchar(100) not null, cm_ContactNo varchar(11) unique not null)
Creating table tbl_BottleManagement:
create table tbl_BottleManagement(bm_Id int primary key auto_increment, bm_Status varchar(10) not
null default 'Active', bm_DateAdded datetime not null default now())
Creating table Borrowing:
create table tbl_Borrowing(cm_Id int, constraint cm_Id_Fk foreign key(cm_Id) references
tbl_CustomerManagement(cm_Id), bm_Id int, constraint bm_Id_Fk foreign key(bm_Id) references
tbl_BottleManagement(bm_Id), DateBorrowed datetime not null default now())
Show borrowed bottles and the info of customer who borrowed it:
select c.cm_Id, c.cm_LastName, c.cm_address, c.cm_ContactNo, b.bm_id as Borrowed_Bottles,
[Link] from tbl_CustomerManagement c inner join tbl_Borrowing b on c.cm_Id=b.cm_Id
I created a view for this:
create view OnSaleBottles as select c.cm_Id, c.cm_LastName, c.cm_address, c.cm_ContactNo,
b.bm_id as Borrowed_Bottles, [Link] from tbl_CustomerManagement c inner join
tbl_Borrowing b on c.cm_Id=b.cm_Id
Retrieve the data on database and put on display table:
Borrow Bottle:
int cmid = [Link]([Link]());
int bmid = [Link]([Link]());
[Link]("insert into tbl_borrowing (cm_id, bm_id, DateBorrowed) values ('"+cmid+"',
'"+bmid+"', default)");
Return Bottle:
int bmid = [Link]([Link]());
[Link]("delete from tbl_borrowing where bm_id='"+bmid+"'");
Update Tbl_Borrowing When is Returned
int bmid = [Link]([Link]());
[Link]("update tbl_BottleManagement set bm_status='Active' where
bm_id='"+bmid+"'");
Update Tbl_Borrowing When is Borrowed
int bmid = [Link]([Link]());
[Link]("update tbl_BottleManagement set bm_status=Borrowed where
bm_id='"+bmid+"'");
Count Borrowed Bottles:
ResultSet rs=[Link]("select *from tbl_BottleManagement where bm_status = 'Borrowed'");
while([Link]())
count++;
Count Available Bottles:
ResultSet rs=[Link]("select *from tbl_BottleManagement where bm_status = Active");
while([Link]())
count++;
Insert Values to tbl_CustomerManagement
INSERT into tbl_CustomerManagement values(default,'Apalisok','Nikkue','Puig','Hong
Kong',09876543210)
Insert Values to tbl_BottleManagement
insert into tbl_BottleManagement values(default,default,default)
Insert Values to tbl_BottleManagement
insert into tbl_Borrowing values(1,5,default)