You are on page 1of 34

PROJECT REPORT

DBMS PROJECT
On

HOSPITAL MANAGEMENT SYSTEM

Submitted by
AQDAS ABRAR
ADITYA SINGH
KARTIKEY SINGH
TARUN PANDEY

RA1711008010284

RA1711008010292

RA1711008010302

RA1711008010262

IN ASSISTANCE WITH Ms.S.Srividhya(101949)

in partial fulfillment for the award of the degree of

BACHELOR OF TECHNOLOGY
IN
INFORMATION TECHNOLOGY
OCTOBER 2019

S.NO TITLES
PAGE
1. ER diagram 3-
8
2. DDL/DML 9
3. SQL constraints 10
4. Retrieving data using select 11-
12
5. Restrictions and sorting 13-
14
6. Aggregate and grouping 15-
16
7. Single row function 17-
19
8. Joins
20-22
9. Subquery 23-
24
10. Normalisation 25-
28
(1)ER DIAGRAM
HOSPITAL MANAGEMENT SYSTEM
ALL TABLES OF HOSPITAL MANAGEMENT SYSTEM
SQL> create table patient(p_id int NOT NULL PRIMARY KEY, name varchar(20),address
varchar(20),days_admitted int,contact_no int);

Table created

SQL> create table record(p_id int , FOREIGN KEY(p_id) REFERENCES patient(p_id),appointment


int,record_no int,decription varchar(30));

Table created

SQL> create table employee(e_id int NOT NULL PRIMARY KEY,salary int,e_address varchar(50),sex
varchar(6),n_id int,e_name varchar(50),phone_no int);

Table created

SQL> create table room(p_id int , FOREIGN KEY(p_id) REFERENCES patient(p_id),room_id int NOT NULL
PRIMARY KEY,room_type varchar(40));

Table created

SQL> create table medicine(p_id int,FOREIGN KEY(p_id) REFERENCES patient(p_id),code int,quantity


int,price int);

Table created

SQL> desc patient;

Name Null? Type

----------------------------------------- -------- ----------------------------

P_ID NOT NULL NUMBER(38)

NAME VARCHAR2(20)

ADDRESS VARCHAR2(20)

DAYS_ADMITTED NUMBER(38)

CONTACT_NO NUMBER(38)

SQL> desc record;


Name Null? Type

----------------------------------------- -------- ----------------------------

P_ID NUMBER(38)

APPOINTMENT NUMBER(38)

RECORD_NO NUMBER(38)

DECRIPTION VARCHAR2(30)

SQL> desc employee;

Name Null? Type

----------------------------------------- -------- ----------------------------

E_ID NOT NULL NUMBER(38)

SALARY NUMBER(38)

E_ADDRESS VARCHAR2(50)

SEX VARCHAR2(6)

N_ID NUMBER(38)

E_NAME VARCHAR2(50)

PHONE_NO NUMBER(38)

SQL> desc room;

Name Null? Type

----------------------------------------- -------- ----------------------------

P_ID NUMBER(38)

ROOM_ID NOT NULL NUMBER(38)

ROOM_TYPE VARCHAR2(40)
SQL> desc medicine;

Name Null? Type

----------------------------------------- -------- ----------------------------

P_ID NUMBER(38)

CODE NUMBER(38)

QUANTITY NUMBER(38)

PRICE NUMBER(38)

INSERT DATA TO TABLE


PATIENT TABLE
SQL> insert into patient values(1001,'Arunim','jaipur',100,98298);

1 row created.

SQL> insert into patient values(1002,'Steve','hyderabad',19,92098);

1 row created.

SQL> insert into patient values(1009,'Rahul','pune',29,92028);

1 row created.

SQL> insert into patient values(1006,'Zikre','rourkela',65,97867);

1 row created.

SQL> insert into patient values(1004,'Aqdas','ranchi',55,97127);

1 row created.

SQL> insert into patient values(1003,'Vishal','rourkela',67,92133);

1 row created.

SQL> insert into patient values(1019,'Fardeen','hyderabad',66,90822);

1 row created.

SQL> insert into patient values(1005,'Aditya','pune',43,96788);

1 row created.

SQL> insert into patient values(1007,'Anuj','raipur',78,95621);


1 row created.

RECORD TABLE
SQL> insert into record values(1001,12,32,'Leg_pain');

1 row created.

SQL> insert into record values(1002,14,34,'Headache');

1 row created.

SQL> insert into record values(1003,16,36,'Backache');

1 row created.

SQL> insert into record values(1004,17,15,'Fever');

1 row created.

SQL> insert into record values(1004,15,78,'Accident');

1 row created.

SQL> insert into record values(1005,11,31,'Fever');

1 row created.

SQL> insert into record values(1006,31,41,'Cold');

1 row created.

SQL> insert into record values(1019,78,39,'Loose Motion');

1 row created.

SQL> insert into record values(1007,45,65,'Fever');

1 row created.

EMPLOYEE TABLE
SQL> insert into employee values(1,10000,'Delhi','male',1,'Arjun',87686);

1 row created.

SQL> insert into employee values(2,500,'Potheri','male',2,'Kartikey',87632);

1 row created.

SQL> insert into employee values(3,5000,'Abode','male',3,'Alok',83132);


1 row created.

SQL> insert into employee values(4,50000,'jaipur','female',4,'Shruti',76232);

1 row created.

ROOM TABLE

SQL> insert into room values(1001,12,'nac');

1 row created.

SQL> insert into room values(1002,14,'ac');

1 row created.

SQL> insert into room values(1003,15,'ac');

1 row created.

SQL> insert into room values(1006,16,'ac');

1 row created.

SQL> insert into room values(1007,17,'nac');

1 row created.

SQL> insert into room values(1019,18,'nac');

1 row created.

MEDICINE TABLE
SQL> insert into medicine values(1001,1,12,200);

1 row created.

SQL> insert into medicine values(1002,2,8,203);

1 row created.

SQL> insert into medicine values(1003,3,6,290);

1 row created.

SQL> insert into medicine values(1006,4,88,870);

1 row created.

SQL> insert into medicine values(1019,5,66,679);


1 row created.

(2) DDL AND DML


1)Create a table name patient and attribute of p_id, name, address,
days_admitted, contact_no?
SQL> create table patient(p_id int NOT NULL PRIMARY KEY, name varchar(20),address
varchar(20),days_admitted int,contact_no int);

2)Display the datatype of all attribute’s in patient table?


SQL> desc patient;

OUTPUT :
Name Null? Type

----------------------------------------- -------- ----------------------------

P_ID NOT NULL NUMBER(38)

NAME VARCHAR2(20)

ADDRESS VARCHAR2(20)

DAYS_ADMITTED NUMBER(38)

CONTACT_NO NUMBER(38)

3)Insert values into the table patient?


SQL> insert into patient values(1001,'Arunim','jaipur',100,98298);

1 row created.

5)Update the city of s_id=001 to bby?

SQL> update patient set address=’bby’ where p_id=1001;


1 row updated.

RESULT

DDL and DML command executed successfully.


(3) SQL CONSTRAINTS

1)Create a table name patient and with a attribute p_id which is not null?
SQL>create table patient(p_id int not null);

Table created

2) Create a table name patient and with a attribute p_id which is unique?
SQL>create table patient(p_id int unique);

Table created

3)Create a table name patient and with a attributes p_id which is a primary key?
SQL>create table patient(p_id int primary key);

Table created

4)Create a table name employee and with a attributes e_id which is a foreign
key and name?
SQL>create table employee(e_id int,foreign key(e_id) referances (e_id),name varchar(20));

Table created

5)Create a table name patient and with a attributes address which a default
constraints “KOLKATA”?
SQL>create table patient(p_id int,address varchar(20) default ‘KOLKATA’);

Table created
RESULT

SQL constraints command executed successfully.

(4) RETRIEVING DATA USING SELECT

1)Display all the columns of table name room?


SQL> select * from room;

OUTPUT
P_ID ROOM_ID ROOM_TYPE

---------- ---------- ----------------------------------------

1001 12 nac

1002 14 ac

1003 15 ac

1006 16 ac

1007 17 nac

1019 18 nac

6 rows selected.

2)Display the columns room_id aliases room_no of table name room?


SQL>select room_id as room_no from room;

OUTPUT

ROOM_NO
----------

12

14

15

16

17

18

6 rows selected.

3)Display the columns room_id and room_type using concatenation and aliases
room_details of table name course?
SQL>select room_id || room_type as room_details from room;

OUTPUT
ROOM_DETAILS

--------------------------------------------------------------------------------

12nac

14ac

15ac

16ac

17nac

18nac

6 rows selected.

4)Remove the duplicate value from room type from table name room?
SQL>select distinct room_type from room;
OUTPUT
ROOM_TYPE

----------------------------------------

nac

ac

RESULT

Retrieving data using select command executed


successfully.

(5) RESTRICTIONS AND SORTING

1)Display the patient ID and name from table name patient who’s address is
rourkela?

SQL> select p_id,name from patient where address ='rourkela';


OUTPUT

P_ID NAME

---------- --------------------

1006 Zikre

1003 Vishal

2)Display all the data of table employee who’s salary is greater than‘1000’?
SQL> select * from employee where salary>1000;

OUTPUT

E_ID SALARY E_ADDRESS SEX

---------- ---------- -------------------------------------------------- ------

N_ID E_NAME PHONE_NO

---------- -------------------------------------------------- ----------

1 10000 Delhi male

1 Arjun 87686

3 5000 Abode male

3 Alok 83132

4 50000 jaipur female

4 Shruti 76232

3)Display all the data of table medicine who’s price range in less then 400?
SQL> select * from medicine where price<400;

OUTPUT :

P_ID CODE QUANTITY PRICE

---------- ---------- ---------- ----------

1001 1 12 200

1002 2 8 203

1003 3 6 290

4)Display the medicine price of table name medicine which in between 200 to
800?
SQL> select * from medicine where price>200 and price<800;

OUTPUT :

P_ID CODE QUANTITY PRICE

---------- ---------- ---------- ----------

1002 2 8 203

1003 3 6 290

1019 5 66 679

RESULT

RESTRICTIONS AND Sorting command executed


successfully.
(6) AGGREGATE AND GROUPING

1)Display the average salary for all the employees in the given table employee?
SQL> select avg(salary)from employee;

OUTPUT :

AVG(SALARY)

-----------

16375

2)Display the minimum and maximum salary in the given table employee?
SQL> select min(salary),max(salary)from employee;

OUTPUT :
MIN(SALARY) MAX(SALARY)

----------- -----------

500 50000

3)Display the count number of employee id from table name employee?


SQL> select count(e_id)from employee;

OUTPUT :

COUNT(E_ID)
-----------

4)Display the total of medicine price in the table name medicine?


SQL> select sum(price)from medicine;

OUTPUT :

SUM(PRICE)

----------

2242

RESULT

Aggregate and grouping command executed successfully.

(7) SINGLE ROW FUNCTION

1)Display the patient ID and patient name and address from patient table where
convert patient name and address into uppercase?

SQL> select p_id,upper(name),upper(address)from patient;

OUTPUT :

P_ID UPPER(NAME) UPPER(ADDRESS)

---------- -------------------- --------------------

1001 ARUNIM BBY

1002 STEVE HYDERABAD


1009 RAHUL PUNE

1006 ZIKRE ROURKELA

1004 AQDAS RANCHI

1003 VISHAL ROURKELA

1019 FARDEEN HYDERABAD

1005 ADITYA PUNE

1007 ANUJ RAIPUR

9 rows selected.

2)Display the patient ID and patient name and address from patient table where
convert patient name and address into lowercase?

SQL> select p_id,lower(name),lower(address)from patient;

OUTPUT :

P_ID LOWER(NAME) LOWER(ADDRESS)

---------- -------------------- --------------------

1001 arunim bby

1002 steve hyderabad

1009 rahul pune

1006 zikre rourkela

1004 aqdas ranchi

1003 vishal rourkela


1019 fardeen hyderabad

1005 aditya pune

1007 anuj raipur

9 rows selected.

3)Display the patient ID and address from table patient and change the first
character of all address to uppercase?

SQL> select p_id,initcap(address)from patient;

OUTPUT :

P_ID INITCAP(ADDRESS)

---------- --------------------

1001 Bby

1002 Hyderabad

1009 Pune

1006 Rourkela

1004 Ranchi

1003 Rourkela

1019 Hyderabad

1005 Pune

1007 Raipur
9 rows selected.

4)Display the patient ID and the length of the name from the table patient use
the character-manipulation function?
SQL> select p_id,name,length(name)from patient;

OUTPUT :

P_ID NAME LENGTH(NAME)

---------- -------------------- ------------

1001 Arunim 6

1002 Steve 5

1009 Rahul 5

1006 Zikre 5

1004 Aqdas 5

1003 Vishal 6

1019 Fardeen 7

1005 Aditya 6

1007 Anuj 4

9 rows selected.

RESULT

Single row function command executed


successfully.
(8) JOINS

1)Display the name from patient table and description from the table record use
inner join?
SQL> select patient.name,record.decription from patient inner join record on patient.p_id = record.p_id;

OUTPUT :

NAME DECRIPTION

-------------------- ------------------------------

Arunim Leg_pain

Steve Headache

Vishal Backache

Aqdas Fever

Aqdas Accident

Aditya Fever

Zikre Cold

Fardeen Loose Motion

Anuj Fever

9 rows selected.

2) Display the appointment from record table and patient first name from the
table patient use left join and order by first name?
SQL>select patient.name,record.appointment from record left join patient on patient.p_id =
record.p_id order by patient.name;

OUTPUT
NAME APPOINTMENT
-------------------- -----------

Aditya 11

Anuj 45

Aqdas 17

Aqdas 15

Arunim 12

Fardeen 78

Steve 14

Vishal 16

Zikre 31

9 rows selected.

3) Display the appointment from record table and patient first name from the
table patient use right join and order by first name?
SQL> select patient.name,record.appointment from record right join patient on patient.p_id =
record.p_id order by patient.name;

OUTPUT :
NAME APPOINTMENT

-------------------- -----------

Aditya 11

Anuj 45

Aqdas 15

Aqdas 17

Arunim 12

Fardeen 78

Rahul
Steve 14

Vishal 16

Zikre 31

10 rows selected.

RESULT

JOINS all command executed successfully.

(9) SUBQUERY
1)Display the name of employee where the salary is minimum?
SQL> select e_name from employee where e_id=(select e_id from employee where salary=
(select min(salary) from employee ));

OUTPUT :

E_NAME

--------------------------------------------------

Kartikey

2) Display the employee_id and name of employee where the employee address
is Delhi?
SQL> select e_id,e_name from employee where e_id=(select e_id from employee where
e_address ='Delhi');

OUTPUT :

E_ID E_NAME

---------- --------------------------------------------------

1 Arjun

3)Display the contact number of the patient of who’s days admitted is 78?
SQL> select contact_no from patient where p_id=(select p_id from patient where
days_admitted =78);

OUTPUT :
CONTACT_NO

----------

95621

4)Display appointment who live in jaipur?


SQL>select appointment from record where p_id = (select p_id from patient where address =
‘jaipur’);
OUTPUT

Appointment

----------------

12

5)Display code , quantity and price of medicine who’s patient is in rourkela?


SQL> select code , quantity, price from medicine where p_id in(select p_id from patient where
address='rourkela');

OUTPUT :

CODE QUANTITY PRICE

---------- ---------- ----------

3 6 290

4 88 870

RESULT
SUBQUERY all command executed
successfully.

(10) NORMALISATION
(1NF,2NF,3NF)

TABLE ROOM
P_ID ROOM_ID ROOM_TYPE
---------- ---------- ----------------------------------------
1001 12 nac
1002 14 ac
1003 15 ac
1006 16 ac
1007 17 nac
1019 18 nac

TABLE medicine

P_ID CODE QUANTITY PRICE


---------- ---------- ---------- ----------
1001 1 12 200
1002 2 8 203
1003 3 6 290
1006 4 88 870
1019 5 66 679

TABLE patient

P_ID NAME ADDRESS DAYS_ADMITTED CONTACT_NO


---------- -------------------- -------------------- ------------- ----------
1001 Arunim jaipur 100 98298
1002 Steve hyderabad 19 92098
1009 Rahul pune 29 92028
1006 Zikre rourkela 65 97867
1004 Aqdas ranchi 55 97127
1003 Vishal rourkela 67 92133
1019 Fardeen hyderabad 66 90822
1005 Aditya pune 43 96788
1007 Anuj raipur 78 95621

TABLE record

P_ID APPOINTMENT RECORD_NO DECRIPTION


---------- ----------- ---------- ------------------------------
1001 12 32 Leg_pain
1002 14 34 Headache
1003 16 36 Backache
1004 17 15 Fever
1004 15 78 Accident
1005 11 31 Fever
1006 31 41 Cold
1019 78 39 Loose Motion
1007 45 65 Fever
TABLE employee

E_ID SALARY E_ADDRESS SEX


---------- ---------- -------------------------------------------------- ----
--
N_ID E_NAME PHONE_NO
---------- -------------------------------------------------- ----------
1 10000 Delhi male
1 Arjun 87686

2 500 Potheri male


2 Kartikey 87632

3 5000 Abode male


3 Alok 83132

E_ID SALARY E_ADDRESS SEX


---------- ---------- -------------------------------------------------- ----
--
N_ID E_NAME PHONE_NO
---------- -------------------------------------------------- ----------
4 50000 jaipur
female
4 Shruti 76232
 This table satisfy all the rule of 2NF:-

RULE
 It should be in 1st normal form.
 It should not have partial dependencies.

 This table satisfy all the rule of 3NF:-


RULE
 It should be in 2nd normal form.
 It should not have transitive dependencies.

RESULT

The table’s of this Hospital Management


System satisfy all the normal
form(1NF,2NF,3NF).
CONCLUSION:
In this project,we developed an Hospital Management System where
the tables have been created and Normalisation has been done for
reducing anomalies.After the normalisation is done queries and
subqueries has been implemented for the tables created for getting the
details of the requirement of the user.Only the backend is done in this
project.This can be used with a frontend page to make an automatic
management system.

You might also like