Blood Bank Database12
Blood Bank Database12
Database
Group Members: Raul Cordero (leader), Purva Chandel, Divina Gorospe
Contents
Modified Project Summary (#4) ............................................................................................................................................................................................................ 2
Tables ........................................................................................................................................................................................................................................................ 3
1|Page
Modified Project Summary (#4)
Our project is based on a Blood Bank Donation System Database. In our project we created multiple tables with multiple attributes each.
Our purpose was to be able to have a database that stored information about the Donor, the Recipient, Medical personnel, how much and when
the blood was donated, and whenever there was a transaction made between the donor, the medical personnel, and the recipient. All tables are
linked together using foreign keys to enforce relationships. We created three different views: PatientSeen, BloodStock, and a PatientList. This adds
security to the individual tables by not showing irrelevant data to unauthorized viewers. The views used joins to combine columns from different
tables. We have utilized the import functionality in MyPHP to add multiple rows of information in all of our tables. This process made it so much
more efficient to populate the tables. Our java code is able to access our database, but will not be able to show the views.
Our Donor and Recipient tables are extremely similar to each other. Both of these tables primary key is the ID attribute. They both include
the person's first name, last name, address, email, phone number, date of birth, and blood type. The MedicalPersonnel table’s primary key is also
the ID attribute. This table includes the same attributes as the Donor and Recipient table with the exception of not including their blood type. Our
BloodDonation tables primary key is the bloodID attribute with the foreign key being donorID which is linked to the Donor table. This table also
includes the date when the blood was donated and the quantity or amount donated. Lastly, our BloodTransaction table has one primary key and
three foreign keys. The primary key is the transacID and the three foreign keys are: empID which is linked to the MedicalPersonnel Table, the
recipientID which is linked to the Recipient table, and the bloodID which is linked to the BloodDonation table.
The first view that we created is the PatientSeen view. This view is for medical personnel who would like to see which patients they’ve seen.
This view includes the medical personnel who either administered donated blood or took blood, the donor's or recipient's name, and the date it
happened. The second view we created was the BloodStock view. This view is seen by the medical personnel. This is just a simple view that shows
all the blood types we have and the quantity of each we have in stock. The final and third view we created is the PatientList view. This view was
made to show certain information about all the patients that came through the blood bank whether they were donating or receiving blood. The
view will include the patient's full name, blood type, age, address, email, and phone number.
The java code that we made will be able to access our database and have access to all five of our tables. This program will start at the main
menu and will first ask the user which table he/she wishes to access or if he/she wishes to terminate the program. Once the user selects the table
of his/her choosing the program will give him/her four options. The four options are: If they wish to add something to the table they are currently
in, view something specifically based on an ID in the table they are currently in, if they wish to print out the whole table in which they are currently
in, or if they wish to go back to the main menu. This program will run forever until the user is back in the main menu and selects to terminate the
program.
2|Page
Tables
3|Page
email varchar (100) not null
phone varchar (20) not null
dob date not null
4|Page
SQL Statements and Screenshots (#1-2)
SQL Statements Screenshot
CREATE TABLE Donor(
donorID INT AUTO_INCREMENT NOT
NULL ,
firstName VARCHAR( 50 ) NOT NULL,
lastname VARCHAR( 50 ) not null,
address VARCHAR( 60 ) not null,
email VARCHAR( 100 ) not null,
phone VARCHAR( 20 ) not null,
dob DATE not null,
bloodType varchar (3)NOT NULL ,
PRIMARY KEY ( donorID )
);
5|Page
SQL Statements Screenshot
CREATE TABLE Recipient(
recipientID INT AUTO_INCREMENT
NOT NULL ,
firstName VARCHAR( 50 ) NOT NULL,
lastname VARCHAR( 50 ) not null,
address VARCHAR( 60 ) not null,
email VARCHAR( 100 ) not null,
phone VARCHAR( 20 ) not null,
dob DATE not null,
bloodType varchar (3)NOT NULL ,
PRIMARY KEY ( recipientID )
);
6|Page
SQL Statements Screenshot
CREATE TABLE MedicalPersonnel(
empID INT AUTO_INCREMENT NOT
NULL ,
firstName VARCHAR( 50 ) NOT NULL ,
lastname VARCHAR( 50 ) NOT NULL ,
address VARCHAR( 60 ) NOT NULL ,
email VARCHAR( 100 ) NOT NULL ,
phone VARCHAR( 20 ) NOT NULL ,
dob DATE NOT NULL ,
PRIMARY KEY ( empID )
);
7|Page
CREATE TABLE BloodDonation(
bloodID INT( 11 ) AUTO_INCREMENT,
donorID INT( 11 ) NOT NULL ,
dateDonated DATETIME NOT NULL ,
quantity INT NOT NULL ,
PRIMARY KEY ( bloodID ) ,
FOREIGN KEY ( donorID ) REFERENCES
Donor( donorID )
);
8|Page
CREATE TABLE BloodTransaction(
transactID INT( 11 ) AUTO_INCREMENT ,
empID INT( 11 ) NOT NULL ,
dateOut DATETIME NOT NULL ,
quantity INT NOT NULL ,
recipientID INT( 11 ) NOT NULL ,
bloodID INT( 11 ) NOT NULL ,
PRIMARY KEY ( transactID ) ,
FOREIGN KEY ( empID ) REFERENCES
MedicalPersonnel( empID ) ,
FOREIGN KEY ( recipientID ) REFERENCES
Recipient( recipientID ) ,
FOREIGN KEY ( bloodID ) REFERENCES
BloodDonation( bloodID )
);
9|Page
create view PatientSeen
as select
concat_ws(' ', m.firstName, m.lastName) as
'Medical Personnel',
concat_ws(' ', r.firstname, r.lastName) as 'Patient
Name',
dateOut as 'Date Seen'
From MedicalPersonnel m, BloodTransaction b,
Recipient r
where m.empID = b.empID AND r.recipientID
= b.recipientID
order by m.lastName ASC;
10 | P a g e
create view PatientList
as select
concat_ws(', ', lastName, firstName) as Name,
bloodType as 'Blood Type',
date_format(from_days(to_days(now())-
to_days(dob)),'%y')+0 as Age,
address as Address,
email as Email,
phone as Phone
from Donor
union
select
concat_ws(', ', lastName, firstName) as
'PatientName',
bloodType as 'Blood Type',
date_format(from_days(to_days(now())-
to_days(dob)),'%y')+0 as Age,
address as Address,
email as Email,
phone as Phone
from Recipient
Order by Name
11 | P a g e
CSV Files (#3)
Table Link
BloodDonation
bloodDonation.csv
additionalBloodDonat
ion.csv
BloodTransaction
bloodTransaction.csv
Donor
donor.csv
MedicalPersonnel
medical
personnel.csv
Recipient
recipient.csv
12 | P a g e
Java File (#5)
Java- Created by Raul, revised by Divina and Purva. We all made the changes to make it user friendly by adding additional code to format the outputs.
Database tables - Created by Divina, rows populated by Purva using csv files. Raul ensured that tables were correctly implemented and accessible using Java.
Final Document - Created by Divina using google docs, revised by Raul and Purva. Everyone had their inputs on different sections.
13 | P a g e