Hospital Management System
Hospital Management System
Using SQL
INTRODUCTION
Statements
Device Used:
Working PC
Software Used:
XAMPP(Local Server of Server)
Command prompt or XAMPP Shell
Patient Table:
Doctor Table:
NurseTable:
Ward Table:
Relationship:-
Attributes:-
Attributes are the properties of the entities and relationship. Descriptor of the
entity. Attributes are elementary pieces of information attached to an entity.
23
Symbols Meaning
Entity
Relationship
Attribute
Key Attribute
column1 datatype,
column2 datatype,
column3 datatype,
....
);
);
CREATE TABLE `doctor` (
`name` varchar(40),
);
);
);
CREATE TABLE `department` (
);
A FOREIGN KEY is a field (or collection of fields) in one table that refers to the
PRIMARY KEY in another table.
The table containing the foreign key is called the child table, and the table
containing the candidate key is called the referenced or parent table.
To create a FOREIGN KEY constraint on the "PersonID" column when the "Orders"
table is already created, use the following SQL:
UPDATE Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Update patient
Set age=50
Where age=58;
DELETE Syntax
The ALTER TABLE statement is used to add, delete, or modify columns in an existing
table.
The ALTER TABLE statement is also used to add and drop various constraints on
an existing table.
To delete a column in a table, use the following syntax (notice that some database
systems don't allow deleting a column):
To change the data type of a column in a table, use the following syntax:
SQL Server
Count():
SUM() Syntax
SELECT SUM(column_name)
FROM table_name
WHERE condition;
SELECT AVG(column_name)
FROM table_name
WHERE condition;
In table “doctor” average salary is calculated as:
SQL JOIN
A JOIN clause is used to combine rows from two or more tables, based on a related
column between them.
The INNER JOIN keyword selects records that have matching values in both tables.
SELECT column_name(s)
FROM table1
ON table1.column_name = table2.column_name;
Select name
From doctor
The HAVING clause was added to SQL because the WHERE keyword could not be
used with aggregate functions.
HAVING Syntax
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);
You can add SQL functions, WHERE, and JOIN statements to a view and present
the data as if the data were coming from one single table.
FROM table_name
WHERE condition;
FROM patient
WHERE department=1;
CONCLUSION
It was a wonderful learning experience for me while working on this project. This
project took me through the various task in SQLand gave me a real insight into the
world of database designing. The joy of working and tackling the various problems
and challenges gave me a feel of database developer. Moreover most of the SQL
operations are learned and analyzed in comprehensive way.