Database Project Hospital Management System
Database Project Hospital Management System
Database Project Hospital Management System
of the medicine by their name, by their ID and by their weightage. This project can access the
record as well as sort the record by their name, by their ID also by their weightage. It can store
new records, edit previous records, delete previous records, add new records at the end of the
existing record. It can tell the location or block where the medicine is kept. It can store
manufacturing and expiry dates of medicines. It can also store which medicine is short in stock and
which one is near to finish soon? It can also store the record of the costumer. It can add new costumer
update the previous record and delete the previous record of the costumer. It can store the number of
medicines bought by the costumer and amount spent by that costumer. It can store the arrival date and
time of the costumer. It can also store the employee record of the medical store. It can store the hours
work rate and salary of the costumers. It can also manage the employee information. This database also
add views for the virtual representation of tables and use different operator to perform different
operation on data. This database also searches the value of the user desired. This pharmacy
Features: -
1. CREATE TABLES.
2. STORE DATA IN TABLES.
3. ADD / DELETE DATA.
4. UPDATE DATA.
5. SEARCHING AND SORTING.
6. CREATE BILLS.
Costumer Entity
Attributes of Costumer Entity
Costumer(Costumer_ID , costumer_name, Arriving_time, contact,
amount_spent, num_of_bougth, Med_ID).
Employee Entity
Attributes of Employee Entity
Employee(Emplyee_ID, employee_name, employee_contact, User_name,
employee_passward, salary, num_hour_work, date_of_joining).
Entity company
Attributes of company Entity
Company(comp_ID, comp_name, comp_city, comp_state, comp_country,
med_ID)
Order Entity
Attributes of order entity
Order(order_ID, order_Disciption , medicine_ID, medicine_quantity, cost_ID,
order_price)
ERD Diagram
Normalizations
Normalization on Medicine Information Table
Medicin Med_na Med_wi Med_Pr Med_co Med_lo Expiry_ Expiry_ Compan
e_ID me etage ice mpany cation Date Time y_Name
Company_Information(medicine_ID,company_ID,comp_Name,comp_country
, comp_city)
The medicine_ID in the company_Information table work as foreign
key. So, the medicine table is in seond normal form.
3NF of Medicine table: -
A relation is in third normal form (3NF) if it is in 2NF and no transitive dependency
exists. It means that the value of any non-key attribute cannot be find by using
the value of another non-key attribute.
The transitive dependency in the Medicine_Information table is as follow.
Medicine_ID ,wietage --> location ,price,expiry_date, expiry_time.
To remove the transitive dependency, we create another table that only
store the medicne_ID, name and wietage.
Medicine_Information_1 table
Medicine_Information_2 Table
Normalization on company table
The attributes of the company entity are as follow.
Company_Information(company_ID,company_name,company_city,company_
country,medicine_ID)
Company_Information_1(company_ID,company_name,company_city,compa
ny_country)
Company_ID is a primary key in Company_Information_1 table.
For repeating groups the another table is
Company_Information_2(company_ID,medicine_ID)
Company_ID attribute in company_Information_2 table is a foreign key from the
company_Information_1 table and medicine_ID in company_Information_2 is a
foreign key from the medicine_Information_1 table.
So, the company_information_1 and company_information_2 table is in 1NF.
Company_Information_3(company_ID,company_name).
After third normal form we have three tables to store the company information as
follow.
Company_Information_1(company_ID,company_country_company_city).
Company_Information_2(company_ID,medicine_ID)
Company_Information_3(company_ID,company_name).
Company_Information_3 table
Company_Information_1 Table
Company_Information_2 Table
Patient_Information_1(costumer_ID,costumer_name,contact,arrival_date,arri
val_time,amount_spent, num_of_bougth).
Patient_Information_2(costumer_ID, medicine_ID)
In the above table costumer_Information_1 costumer_ID attribute work as
primary key. The costumer_ID is in costumer_Information_2 is a foreign key from
costumer_Information_1 table and medicine_ID is a foreign key from
Medicine_Information_1 table.
Patient_Information_3(costumer_ID,costumer_name).
After 3NF we have three costumer tables to store the costumer Information as
follow.
Patient_Information_1(costumer_ID,arrival_date,arrival_time,amount_spent,
num_of_bought,contact)
Patient_Informaation_2(costumer_ID,medicine_ID).
Patient_Information_3(costumer_ID,costumer_name).
Patient_Informatio_3 table
Patient_Information_1 Table
Patient_information_2 Table
Normalization on Employee_table
Emp Emp_ Emp_ DOJ Num_hour user_ passwor country city contact
_ID name salary _work name d
Employee_Information_2(emp_ID, password)
The emp_ID attribute in the Employee_Information_2 is a foreign key from
Employee_Information_1 table. After the 2NF we have 2 employee_Information
tables are as follow.
Employee_Information_1(emp_ID, emp_name, contact, DOJ, emp_salary,
NUm_Work_Hour,emp_country,emp_city,emp_user_name).
Employee_Information_2(emp_ID, emp_password).
Emplyee_Information_3(emp_ID,email)
After third normal form we have three tables to store the information of the
employee are as follows.
Employee_Information_1(emp_ID,emp_contact,DOJ,num_hour_work,emp_c
ountry,emp_city,salary).
Employee_Information_2(emp_ID,emp_user_name,emp_password).
Employee_Information_3(emp_ID,emp_name,emp_status).
Employee_Information_1 Table
Employee_Information_2 Table
Employee_Information_3 Table
Order_Information_2(order_ID,medicine_ID,medicine_quantity).
The order_ID attribute in a Order_Information_1 table is a foreign key from the
Order_Information_1 table and medicine_ID is a foreign key from the
Medicine_Information_1 table.
The costumer_ID is a foreign key so create another table to store the value of the
costumer_ID along with the order_ID.
Order_Information_3(order_ID,costumer_ID)
In order_Information_3 table, order_ID attribute is a foreign key from the
order_Information_1 table and costumer_ID is a foreign key from
Patient_Information_1 table.
After first normal form we have two order_Information tables are as follows.
Order_Information_1(order_ID,order_disc,date,time,order_total).
Order_Information_2(order_ID,medicine_ID,medicine_quantity).
Order_Information_3(order_ID, costumer_ID)
Order_Information_4(order_ID,order_discription)
After 3NF we have four tables to store the information of orders.
Order_Information_1(oder_ID,order_date,Order_time,order_total).
Order_Information_2(order_ID,medicine_ID,medicine_quantity).
Order_Information_3(order_ID,costumer_ID).
Order_Information_4(Order_ID,order_discripion).
Order_Information_1 Table
Order_Information_2 Table
Order_Information_3 Table
Order_Information_4 Table
Create Table Medicine_Information
create table
Medicine_Information( medicine_ID
medicine_name varchar(30),
wietage float
expire_date date,
expire_time time,
loction varchar(20),
price float,
num_of_medicine float
BLock',10,500);
insert into Medicine_Information_2 values(7,'2028-4-8','9:20:40','c BLock',25,700);
company_country varchar(35),
company_city varchar(30)
values(10,14);
Patient_Information_1( costumer_ID
costumer_name varchar(30),
arrival_date date,
arrival_time time,
amount_spent float,
num_of_bought int,
contact varchar(30)
varchar(30),
DOJ date,
num_hour_work time,
emp_country varchar(30),
emp_city varchar(30),
salary float
);
select*from Employee_Information_2;
emp_name varchar(30),
emp_status varchar(30)
)
select *from Employee_Information_3;
values(10,'Majeed','SecrityGaurd');
Create order_Information_1 table
create table order_Information_1(
order_date date,
order_time time,
order_total float
medicine_quantity int
values(5,12,2);
select *from order_Information_2;
order_discription varchar(30)
*from order_Information_4;
Views
Medicine View on Two Tables
create view Medicine_View
as select
m.medicine_ID,m.medicine_name,m.wietage,m1.expire_date,m1.expire_time,m1.loction,m1.n
um_of_medicine,m1.price
from Medicine_Information m,Medicine_Information_2 m1 where
m1.medicine_ID=m.medicine_ID;
drop view Medicine_View;
select *from Medicine_View;
Order_Costumer_Medicine_View on Six
Tables
create view Order_Costumer_Medicine_View as
select
o4.order_ID,o4.order_discription,o1.order_date,o1.order_time,o1.order_total,m1.medicine_ID
, m1.medicine_name,m1.wietage,o2.medicine_quantity,p1.costumer_ID,p1.costumer_name
from order_Information_1 o1,order_Information_2 o2,order_Information_3 o3,
order_Information_4 o4,Patient_Information_1 p1,Medicine_Information m1
where o1.order_ID=o2.order_ID and o1.order_ID=o3.order_ID and o1.order_ID=o4.order_ID
and o2.medicine_ID=m1.medicine_ID and o3.costumer_ID=p1.costumer_ID
select *from Order_Costumer_Medicine_View;
Functions
Sum function to calculate Total Orders Price.
select sum(o.order_total) as total_Order_Price from order_Information_1 o;
Delete Trigger
create trigger Medicine_Deleted_Trigger
on Medicine_Information
after delete
as begin
print 'One Medicine Record has been deleted from Medicine table'
end;
Insert Trigger
create trigger Medicine_insert_trigger
on Medicine_Information
after insert
as begin
print 'New Medicine has been inserted in Medicine Table'
end;
Update Trigger.
create trigger Medicine_Update_trigger
on Medicine_Information
after update
as begin
print'Record is updated in Medicine Table'
end;