Professional Documents
Culture Documents
CARDIC Hospital has recently renovated its building. This has allowed it to
expand its perimeter to include more space for equipment and accommodate more
patients. However, this brings with it an issue of how to store all the necessary data
if the new found patients and work in general. Our team was asked to help suggest
and implement a solution to fix the issue at hand. After much deliberation and
research, we have found that a Database should be build along with a Database
Management System (DBMS). A Database Management System is used to manage
the database along with edit or insert content into it. It’s a software designed to
control a storage of data called a database. Based on our research, the easiest and
most effective programming languages for the job include C, C++, Java, Ruby On
Rails, Python and SQL. After careful consideration, we decided to go with SQL as
it is the most straightforward in its syntax, is fairly human-readable and is
essentially centered around database management, compared to the more diverse
use of the other languages.
Use-Case Diagram
Business Rules:
These are the Business Rules implemented in the database:
1. All Patients must have their name, contact details, current address and next
of kin information registered, regardless of whether they are in or out.
3. Each Ward must have three nurses. One Head Nurse and two General
Nurses.
4. Each Ward must have a telephone extension.
8. Each examination room record must contain the name of the doctor in
charge.
1NF:
1NF is the first normal form for any table. There are only two rules:
Each table cell should contain a single value.
Each record needs to be unique.
2NF:
Patient Table:
Before:
After:
Before:
Diagram – Appointment
After:
Diagram – Doctor_ID
Diagram – Appointment_Num
The appointment table can be broken down into two tables, which are
Appointment Number and Doctor ID. Appointment Number uses the appointment
number as a primary key, whereas Doctor ID uses Staff Number as a primary key.
Both tables have attributes that are functionally dependant on the primary key.
Examination Room:
After:
Diagram – Nurses
The Nurses table is already coherent with the characteristics for 2NF.
3NF:
Ward:
Diagram – Ward
No adjustments are made as it fits the criteria for 3NF.
Nurse:
Before:
Diagram – Nurse
After:
Diagram – Salary
SQL Statements:
a) 1. Ward
create table Ward (No int, Name VARCHAR(255), Number_of_Beds
VARCHAR(255), Gender VARCHAR(255), Tel_Extension
VARCHAR(255));
(13, 'Urology', '14', 'M', 'Ext 013'), (14, 'Ophtamology', '14', 'Mix', 'Ext
014'),
(15, 'Obstetric Gynaecology', '14', 'F', 'Ext 015'), (16, 'Oncology', '14',
'Mix' , 'Ext 016'),
2. Nurse
create table Nurse(Name VARCHAR(255), Staff_Num int, Tel_Num
VARCHAR(255), DoB VARCHAR(255), Gender VARCHAR(255),
Position VARCHAR(255), Salary int);
3. Doctors
create table Doctor(Name VARCHAR(255), Staff_Num int, Specialty
VARCHAR(255), Tel_Ext VARCHAR(255));
4. Patients
create table patient(Patient_Type VARCHAR(255),Name VARCHAR(255),
Address1 VARCHAR(255), Tel_Num1 VARCHAR(255), DoB
VARCHAR(255), Gender VARCHAR(255), Date_Of_Regist
VARCHAR(255), Name_of_Kin VARCHAR(255), Relationship
VARCHAR(255), Address VARCHAR(255), Tel_Num int, Ward Int, Bed
int, Duration_of_Stay VARCHAR(255), Date_of_Arrival VARCHAR(255),
Date_of_Departure VARCHAR(255), Actual_Date_of_Departure
VARCHAR(255));
insert into patient(Patient_Type, Name, Address1, Tel_Num1 , DoB,
Gender, Date_Of_Regist, Name_of_Kin, Relationship, Address, Tel_Num,
Ward, Bed, Duration_of_Stay, Date_of_Arrival, Date_of_Departure,
Actual_Date_of_Departure)
ii. Identify the total number patients allocated at each ward, categorised
by gender.
select count(Patient_Number) as Male_Ward1 from Patients where
Ward = 1 and Gender = 'M';
select count(Patient_Number) as Female_Ward1 from Patients where
Ward = 1 and Gender = 'F';
select count(Patient_Number) as Male_Ward2 from Patients where
Ward = 2 and Gender = 'M';
select count(Patient_Number) as Female_Ward2 from Patients where
Ward = 2 and Gender = 'F';
select count(Patient_Number) as Male_Ward3 from Patients where
Ward = 3 and Gender = 'M';
select count(Patient_Number) as Female_Ward3 from Patients where
Ward = 3 and Gender = 'F';
select count(Patient_Number) as Male_Ward4 from Patients where
Ward = 4 and Gender = 'M';
select count(Patient_Number) as Female_Ward4 from Patients where
Ward = 4 and Gender = 'F';
select count(Patient_Number) as Male_Ward5 from Patients where
Ward = 5 and Gender = 'M';
select count(Patient_Number) as Female_Ward5 from Patients where
Ward = 5 and Gender = 'F';
select count(Patient_Number) as Male_Ward6 from Patients where
Ward = 6 and Gender = 'M';
select count(Patient_Number) as Female_Ward6 from Patients where
Ward = 6 and Gender = 'F';
select count(Patient_Number) as Male_Ward7 from Patients where
Ward = 7 and Gender = 'M';
select count(Patient_Number) as Female_Ward7 from Patients where
Ward = 7 and Gender = 'F';
select count(Patient_Number) as Male_Ward8 from Patients where
Ward = 8 and Gender = 'M';
select count(Patient_Number) as Female_Ward8 from Patients where
Ward = 8 and Gender = 'F';
select count(Patient_Number) as Male_Ward9 from Patients where
Ward = 9 and Gender = 'M';
select count(Patient_Number) as Female_Ward9 from Patients where
Ward = 9 and Gender = 'F';
select count(Patient_Number) as Male_Ward10 from Patients where
Ward = 10 and Gender = 'M';
select count(Patient_Number) as Female_Ward10 from Patients where
Ward = 10 and Gender = 'F';
select count(Patient_Number) as Male_Ward11 from Patients where
Ward = 11 and Gender = 'M';
select count(Patient_Number) as Female_Ward11 from Patients where
Ward = 11 and Gender = 'F';
select count(Patient_Number) as Male_Ward12 from Patients where
Ward = 12 and Gender = 'M';
select count(Patient_Number) as Female_Ward12 from Patients where
Ward = 12 and Gender = 'F';
select count(Patient_Number) as Male_Ward13 from Patients where
Ward = 13 and Gender = 'M';
select count(Patient Number) as Female Ward13 from Patients where
Ward = 13 and Gender = 'F';
select count(Patient_Number) as Male_Ward16 from Patients where
Ward = 16 and Gender = 'M';
select count(Patient_Number) as Male_Ward17 from Patients where
Ward = 17 and Gender = 'M';
iii. List the number of currently available beds that are allocated in the
neurology ward.
iv. List the details of patients whose stays at the hospital exceed the
expected duration of stays at the ward, ordered by patient’s name.
select *from Patients where date_of_departure
>actual_date_of_departure order by Name ASC;