Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Team A - Deliverable 2
Contents
1
2
3
Introduction ................................................................................................................... 2
Original Relational Schema.......................................................................................... 2
Changes to Relational Schema.................................................................................... 2
3.1 Blood Type............................................................................................................... 2
3.2 Primary Keys ........................................................................................................... 3
3.3 Patient Notes Relation............................................................................................. 4
3.3.1 Attribute Description.......................................................................................... 4
3.3.2 First Normal Form ............................................................................................. 5
3.3.3 Second Normal Form ........................................................................................ 5
3.3.4 Third Normal Form ............................................................................................ 5
3.3.5 Boyce-Codd Normal Form ................................................................................ 5
3.3.6 Fourth Normal Form.......................................................................................... 5
3.4 Revised Relational Schema .................................................................................... 6
4 Implementing the schema ............................................................................................ 6
5 Sample Data................................................................................................................. 7
6 Views ............................................................................................................................ 7
6.1 Blood Type (View 1) ................................................................................................ 7
6.2 Wards (View 2) ........................................................................................................ 8
6.3 Doctors Appointments (View 3) .............................................................................. 9
6.4 Occupied Bed (View 4)............................................................................................ 9
7 SQL Queries ............................................................................................................... 10
7.1 Patient Details (SQL Query 1) ............................................................................... 10
7.2 Patient Occupyind a Bed (SQL Query 2) .............................................................. 11
7.3 Bed Occupation (SQL Query 3)............................................................................. 11
7.4 Daily Patients on a Ward (SQL Query 4) .............................................................. 12
7.5 Speciality Nurse (SQL Query 5) ............................................................................ 12
7.6 Unoccupied beds (SQL Query 6) .......................................................................... 13
7.7 Nurse Specialities (SQL Query 7) ......................................................................... 13
7.8 Timed Clinic Appointments (SQL Query 8) ........................................................... 14
7.9 Change Appointment (SQL Query 9) .................................................................... 14
7.10 Ward Nurses (SQL Query 10) ............................................................................... 15
7.11 Doctors Patient List (SQL Query 11) .................................................................... 16
7.12 Nurses on Duty (SQL Query 12) ........................................................................... 17
8 References ................................................................................................................. 17
APPENDIX I Test Data .................................................................................................. 18
CREATE TABLE statements ......................................................................................... 18
Sample Data .................................................................................................................. 20
APPENDIX II - Example Screen Shots ............................................................................. 26
APPENDIX III - Data Dictionary ........................................................................................ 30
Page 1 of 1
Introduction
This system has been designed to facilitate the accessibility of hospital appointment records and in-patient
stays. Included are details of patients and staff combining to create a full medical history.
This deliverable is concerned with the implementation of the relational schema using PostgreSQL ORDBMS.
The implementation of the schema uses the design produced in deliverable 1.
The relations in 4NF from deliverable 1 are shown in the following table. Primary Keys are shown in red, foreign
keys are bordered with blue.
Entity
Attributes
Appointment
( appointmentNo.
Bed
bedNo.
wardID
Doctor
doctorID
GMCno
employeeID )
Employee
employeeID,
firstName,
InpatientStay ( admittanceNo.
date
time
surname,
admitDate,
Nurse
nurseID
UKCCPIN,
Patient
patientID,
firstName,
Qualification
( qualificationID
Shift
ShiftID
Treatment
Ward
NurseQual.
location
doctorID
address,
telNo,
treatmentNo )
dOB
jobType,
natInsNo,
doctorID
bedID,
treatmentNo )
nHSNo.,
DOB,
bloodType )
employeeID, )
surname,
address,
telNo,
nurseID
date
shift
wardID
treatmentNo,
notes,
patientID
wardID
wardName,
floor,
nurseID
qualification )
)
)
qualificationID )
qualificationID )
3.1
Blood Type
This value was originally designed as a char(2) to cater for the A, B & O blood types with their +/- Rh marker
suffix. Unfortunately this did not take account of the AB+ & AB- blood types so the column was amended to a
Varchar(3)
Page 2 of 2
3.2
Primary Keys
The original schema defined the majority of Primary Keys as unique, not null, CHAR(x) data types with a leading
alpha character for identification as follows:
Data
Type
Nulls?
Domains
Char(5)
E0000-E9999
Char(5)
D0000-D9999
nurseID
char(5)
N0000-N9999
qualification
qualificationID
Uniquely
qualification
char(5)
Q0000-Q9999
patient
patientID
char(6)
P00000-P99999
treatment
treatmentID
char(7)
T000000T999999
appointment
appointmentID
Uniquely
identifies
appointment
char(6)
A00000-A99999
ward
wardID
char(2)
00-99
bed
bedID
char(3)
000-999
inpatientStay
inpatienStayID
char(6)
I00000-I99999
shift
shiftID
char(6)
S0000-S9999
Entity
Attribute
Description
employee
employeeID
Uniquely
employee
doctor
doctirID
nurse
identifies
an
identifies
an
2. Capture the numeric part of the expression by left trimming the D and leading zeros
numberPart = ltrim(maxID,D0) = 12
3. Convert this to an integer using the cast function
intNumber = CAST(numberPart AS integer) = 12
4. Increment the integer
intNumber = intNumber +1 = 13
5. Cast the integer back to a VARCHAR. VARCHAR is used as a CHAR appends unwanted spaces at
the end of the string.
strNumber = CAST(incNumber AS varchar(4)) = 13
6. Convert the string to a four digit string with leading zeros by left padding with 0
digitString = lpad(strNumber, 4, 0) = 0013
7. Prefix the digit string by concatenating with the original identifier prefix
nextKey = D || digitString = D0013
Page 3 of 3
3.3
Testing of the database highlighted that, although there is a field in the treatment table for recording a note
(which may be sufficient for a one off appointment), there is not much scope for making several notes, especially
when the patient may stay as an inpatient for a longer period of time, or where a treatment may involve several
appointments. The original design meant that a single treatment can have many appointments / inpatient stays,
but only a single note per treatment. A new relation, patientNotes, was added to facilitate this.
3.3.1
Entity
Attribute Description
Attribute
Data type
Nulls?
Domains
series
Integer
date
Todays date
int
Integer
int
Integer
text
Free text
PatientNotes NotesID
Description
Uniquely identifies a single note written by a doctor
noteDate
doctorID
Page 4 of 4
3.3.2
The PatientNotes table is in 1NF as, for each relation, the intersection of each row and column contains one and
only one value. There are no empty cells within the table.
notesid
notedate
doctorid
treatmentid
doctorsnote
01/01/2000
203
90
05/09/2005
203
400
06/12/2005
203
400
06/12/2005
203
400
01/02/2006
215
401
01/02/2006
216
401
3.3.3
The PatientNotes table is in 2NF as the only candidate key is the Primary key so every non-candidate-key
attribute is fully functionally dependent on the primary key.
3.3.4
The PatientNotes table, which is in 1NF & 2NF, is in 3NF as no non-primary-key attribute is transitively
dependent on the primary key.
fd1
notesid -> notedate, doctorid, treatmentid, doctorsnote
3.3.5
The only determinate is the notesid attribute which is the only candidate key and therefore the primary key.
Therefore this table is in BCNF as all determinants are a candidate key for the relation.
3.3.6
This is also in 4NF as it is in BCNF and does not contain any non-trivial multi-valued dependencies.
Page 5 of 5
3.4
The revised relations in 4NF are shown in the following table. Primary Keys are shown in red, foreign keys are
bordered with blue.
Entity
Attributes
Appointment
( appointmentNo.
aptdate
Bed
bedNo.
wardID
Doctor
doctorID
GMCno
employeeID )
Employee
employeeID,
firstName,
InpatientStay ( admittanceNo.
apttime
surname,
admitDate,
Nurse
nurseID
UKCCPIN,
Patient
patientID,
firstName,
Qualification
( qualificationID
Shift
ShiftID
Treatment
Ward
location
doctorID
address,
telNo,
treatmentID )
dOB
jobType,
natInsNo,
doctorID
bedID,
treatmentID )
nHSNo.,
DOB,
bloodType )
employeeID, )
surname,
address,
telNo,
nurseID
shiftDate
shift
wardID
treatmentID,
notes,
patientID
wardID
wardName,
floor,
NurseQual.
nurseID
PatientNotes
notesID
doctorsNote
qualification )
)
qualificationID )
qualificationID )
notesDate
doctorID
treatmentID
In order to implement the relational schema, Structured Query Language (SQL) was used. SQL is a database
language that allows databases to be created, data to be inserted, modified and deleted from the database, and
allows queries on the data within the database to be performed.
PostgreSQL database management system was used to implement the relational schema. This was accessed
using DBVisualiser. A database management system (DBMS) is used to build, manage and control access to a
database.
The SQL Data Definition Language (DDL) allows databases to be created. Using SQL, a schema (collection of
database objects) is created, and the relations derived in deliverable 1 (shown in section 2), are converted into
tables.
The schema is created using the statement:
CREATE SCHEMA [Name | AUTHORISATION CreatorIdentifier]
Due to authorisation restrictions with PostgreSQL, default schemas are allocated to users. The name of the
schema is the same as the user's username, and authorisation is restricted solely to that user.
To create tables for the relations, the following statement was used:
CREATE TABLE TableName (
columnName1 dataType [NOT NULL],
...
columnNameN dataType [NOT NULL],
[PRIMARY KEY (listOfColumns),]
{[UNIQUE (listOfColumns)]}
{[FOREIGN KEY (listOfForeignKeyColumns) REFERENCES ParentTableName,]}
Page 6 of 6
The 'CREATE TABLE' statement creates a table called 'TableName'. For the implementation of this
database, the table names are the same as the relation names given in Section 3.
Columns are created within the table that correspond to the attributes of the relation. The columns are
assigned the data types as given in the fig32 in Appendix II.
'NOT NULL' is used to indicate that data must always be entered in each row of the column - cannot be
nudl.
For each table, a primary key must be specified. The primary keys are those identified in fig 5in section
3.
The UNIQUE statement is used to ensure the uniqueness of for any alternate keys used within the table.
The FOREIGN KEY statement is used to show that a foreign key has a relationship with another table.
Foreign keys were identified in deliverable 1 and are shown in fig 5 in section 3.
'Serial' is just for setting up unique primary keys
A listing of all the 'Create Table' commands that were used to set up the database is shown in Appendix I. The
'Create Table' statements were executed in the order shown. This is because certain tables had to be created
first due to the foreign key assignments. In order to maintain referential integrity, a table with foreign keys cannot
be created unless the table that the foreign key references already exists.
Sample Data
A sample of the data used for populating the database is shoen in Appendix I. The actual data is included as text
files as part of the submission. Sufficient data has been generated to allow queries to be tests to see if they will
give the correct result, regardless of data values.
To add data to the database, the INSERT statement was used as it was not possible to use the COPY command
for inserting bulk data into the dabase on the student server due to super user constraints:
INSERT INTO TableName VALUES (dataValueList)
'dataValueList' is the list of data that is to be added to the table. The number of items in the list must
match the number of columns in the table. The data type of each item must also match with that
specified for each column.
The complete list of commands for loading the data is contained in the directory that accompanies this report.
Each set of INSERT commands are contained in a text file and, again to the foreign key assignments, must be
loaded in the correct numerical sequence as defined by the filenames.
The sample data for the PatientNotes was loaded as a scenario following the progress of a single patient
through the hospital system. This is documented in Patient Treatment.pdf, which is also contained within the
accompanying directory .
Views
Task:
Define specialist views which are appropriate to various sub-groups or individual users
A set of 3-4 view definitions (create 'view' commands), with copies of the output you obtain, when you
list these views. A view definition, in this context, consists of both the English explanation of what the
view is intended to do AND the SQL command itself.
Views are used for various reasons, such as used to hide parts of the database from certain users or allowing
the presentation of the data within the database to be customised to specific users. A view looks like a table,
with columns and data, but does not necessarily exist as a relation within the relational schema. A view is a
query on one or more tables, or other views. The CREATE VIEW statement is used to create a view.
6.1
The first view is PatientBloodtype which shows only the columns containing the patients first and last name and
their blood type. From this view I have selected only patients with a blood type of B+
Create a view of patients' names and bloodtypes:
Page 7 of 7
surname
bloodtype
Jessica
Williams
Ryan
Paterson
Jacob
Robertson
Jose
Smith
Michael
Ross
Joseph
Wilson
Kyle
Morrison
Nicole
Anderson
Adam
Jones
Fig 6. View 1 output
6.2
B+
B+
B+
B+
B+
B+
B+
B+
B+
Wards (View 2)
The view WardSpecialism returns the specialism associated with each ward and the floor that the ward is on.
Note that the specialism is referred to as qualification in the database, which links it to nurse qualifications. All
wards are selected in the sample output.
Create a view of specialisms, ward names and floors:
CREATE VIEW WardSpecialism
AS SELECT q.qualification,w.wardname, w.floor
FROM Qualification q, Ward w
WHERE q.qualificationID = w.qualificationID
ORDER BY q.qualification;
Using view 'WardSpecialism', show all ward names, their specialisms and the floor that the ward is on:
SELECT * FROM WardSpecialism;
Output:
qualification
wardname
floor
Cardiology
Dermatology
Endocinology
General
General
General
General
General
General
General
General
General
General
Gynaecology
Haematology
2
1
2
G
1
G
2
G
2
G
1
2
1
G
G
Page 8 of 8
Blakeney Ward
Heydon Ward
Denton ward
Buxton Ward
Hethel Ward
1
1
1
2
G
6.3
The view DoctorAppt displays the Doctor ID, Appointment number, Date, Time and location of scheduled patient
appointments. The sample output data is for the Doctor ID 205 on 9th Feb 2006.
NB Date format must be set to European (set datestyle to 'European';)
Create a view of doctorID, appointmentNo, aptdate, apttime and location:
CREATE VIEW DoctorAppt
AS SELECT d.doctorID,a.appointmentNo,a.aptdate,a.apttime,a.location
FROM doctor d, appointment a
WHERE d.doctorID=a.doctorID
ORDER BY a.aptdate;
Using view 'DoctorAppt', show appointment details for doctor 205 on 09/02/2006:
SELECT * FROM DoctorAppt
WHERE doctorID=5 AND aptdate = '09/02/2006';
Output:
doctorid appointmentno
205
205
6.4
aptdate
apttime
115
09/02/2006 14:00:00
116
09/02/2006 16:00:00
Fig 8. View 3 output
location
clinic 5
clinic 1
View 4 shows which bed and ward a patient is or has been on during an inpatient stay. The SELECT query
below searches for all patients with the surname Brown who have had an inpatient stay.
Create a view of patient-ward allocations:
CREATE VIEW PatientWard
AS SELECT p.patientID,p.firstname,p.surname, b.bedID,w.wardname
FROM Patient p, Treatment t, InPatientStay i, Bed b, Ward w
WHERE p.patientID=t.patientID AND t.treatmentID = i.treatmentID AND i.bedID = b.bedID
AND b.wardID = w.wardID
ORDER BY p.patientID;
Using view 'PatientWard', show patient-ward allocations for patients with the surname 'Brown':
SELECT * FROM PatientWard
WHERE surname = Smith;
Output:
patientid
20
58
58
77
77
96
96
firstname
surname
bedid
wardname
Stephanie
Smith
44
Dilham Ward
David
Smith
10
Blakeney Ward
David
Smith
37
Denton ward
Jacob
Smith
14
Buxton Ward
Jacob
Smith
26
Coronary Care Unit
Courtney
Smith
30
Coronary Care Unit
Courtney
Smith
42
Dilham Ward
Fig 9. View 4 output
Page 9 of 9
To only select patients admitted on a particular day, an extra clause with the date would be needed as shown
below.
SELECT * FROM PatientWard
WHERE surname = 'Smith' AND patientID IN (
SELECT patientID FROM Treatment
WHERE treatmentID IN (
SELECT treatmentID FROM InPatientStay
WHERE admitDate = '08/01/2006'));
Output:
patientid firstname surname bedid
20
wardname
Stephanie Smith
44
Dilham Ward
Fig 10. View 4 output with extra clause
th
Therefore Stephanie Smith was the only patient with the surname Smith admitted on the 8 January 2006.
SQL Queries
This section defines SQL queries which could be used as pre-programmed queries by users. Included are a set
of 12 SQL queries, of varying complexity, with the results of the output obtained when you run the queries were
run. Both the English explanation of what the query is intended to do AND the SQL query itself have been given.
An SQL query is often in the form:
SELECT {*|[columnExpression [AS newNAME]],[...]}
FROM TableName [alias] [...]
WHERE condition
The select statement is used to find and show data from one or more database tables. Following 'SELECT', the
columns that you want to be displayed can be specified. An asterisk can be used to select all columns. 'FROM' is
used to specify the table(s) from which the data will be returned. 'WHERE' is used as a filter to return only those
rows that satisfy a certain condition. There are other key words that are used with the select statement; these will
be defined when used in the following queries.
7.1
Page 10 of 10
7.2
Show all details of the patient who was admitted to bed 220 on 26th Jan 2006.
SELECT *
FROM patient
WHERE patientid =
(SELECT patientid
FROM treatment
WHERE treatmentid =
(SELECT treatmentid
FROM inpatientstay
WHERE bedid ='20' AND admitdate='26/01/2006'));
This query uses three tables, Patient, Treatment and InPatientStay. A search of the InpatientStay table is carried
out for all rows where the bedID is equal to '220' and the admitdate is equal to '26/01/2006'. Only the
treatmentIDs from these rows are returned. The Treatment table is then searched for all rows where the
treatmentIDs found in the InpatientStay table match a treatmentID in the Treatment table. Only the patientIDs
from the Treatment table are returned. A search is then carried out of the Patient table for all rows where the
patientIIDs found in the Treatment table match a patientID in the Patient table. All of the columns from any
matching rows are then shown.
Output:
patientid firstname surname
60
Andrew
Williams
address
telno
nhsno
dob
bloodtype
01263 648383
1948638105
17/08/1957
O+
7.3
Show names and patient IDs of patients who have stayed in bed 220:
SELECT firstname,surname,patientid
FROM patient
WHERE patientid IN
(SELECT patientid
FROM treatment
WHERE treatmentid IN
(SELECT treatmentid
FROM inpatientstay
WHERE bedid ='20' ));
This query looks at three tables, Patient, Treatment and InPatientStay. 'IN' is used to test a data value for
membership. A search of the InPatientStay table is performed for all treatments with a bedID of '220'. The
treatmentID for each matching row is returned. Each row of the Treatment table is then tested to see if the
treatmentID is a member of the set of results returned from the InpatientStay table. The patientIDs from all
matching rows are returned. Each row of the Patient table is then tested to see if the patientID is a member of
the set of results returned from the Treatment table. The firstname, surname and patientID of all matching rows
are returned.
Output:
firstname surname patientid
Jacob Robertson
27
Andrew Williams
60
Brian
Walker
90
Fig 13. SQL query 3 output
Page 11 of 11
7.4
ID's, names and addresses of patients admitted to the Buxton Ward on the 27th Jan 2006.
SELECT patientid,firstname,surname,address
FROM patient
WHERE patientid IN
(SELECT patientid
FROM treatment
WHERE treatmentid in
(SELECT treatmentid
FROM inpatientstay
WHERE admitdate ='27/01/2006' AND bedid IN
(SELECT bedid
FROM ward
WHERE wardid =
(SELECT wardid
FROM ward
WHERE wardname= 'Buxton Ward'))));
This query looks at four tables, Patient, Treatment, InPatientStay and WARD. The wardID of Buxton Ward is
found first of all. All rows in the Bed table are then searched for wardIDs that match the wardID of Buxton ward.
The InpatientStay table is then searched for rows where admitDate is 27/01/2006 and where the assigned bed is
in Buxton Ward. The treatmentIDs of all matching rows are returned. The Treatment table is searched next for all
rows where the treatmentID is also a member of the set of previously returned treatmentIDs. The patientIDs of
all matching rows are returned. Finally, the Patient table is searched for all rows where the patientID is also in
the set of previously returned patientIDs. The patientID, firstname, surname and address of all matching rows
are then displayed.
Output:
patientid firstname surname
65
66
67
68
7.5
address
Ryan Robertson
98 Norwich Road, New Costessey
Robert Campbell
1 Tickle Avenue, Lourd
Nicholas Stewart Fordham House, Cheese Road, Walsingham
Sarah Anderson
2The Croft, Guist
Fig 14. SQL query 4 output
Output:
firstname surname employeeid
William
Moon
53
Xander
Nappy
54
John
Lennon
83
Paul McCartney
84
Fig 15. SQL query 5 output
7.6
7.7
Output:
qualification
Cardiology
Renal
Dermatology
Fig 17. SQL query 7 output
7.8
7.9
aptdate
apttime
location
doctorid
treatmentid
1
1
6
6
1
1
11
43
75
111
143
175
Change location of appointments in clinic 1 between 01/02/2006 and 28/02/2006 from clinic 1 to a new 'clinic 9',
then show the names and addresses of all affected patients.
UPDATE appointment SET location = 'clinic 9'
WHERE location = 'clinic 1'
AND aptdate BETWEEN '1/2/2006' AND '28/2/2006';
SELECT surname, firstname, address
FROM patient INNER JOIN treatment USING (patientid)
WHERE treatmentid IN
(SELECT treatmentid
FROM appointment
WHERE location ='clinic 9')
ORDER BY surname;
This query uses four new keywords:
INNER JOIN is used to produce the Cartesian product of subsets of two tables. Tables are joined by
forming pairs of related rows. A column is specified where matching data is used to join the tables. An
inner join omits rows with no matching data. In the above query, Patient and Treatment tables are
combined. Rows that have a matching patientID are combined. 'USING' is used to specify the column in
the tables to use as matching data.
This query looks at three tables, Appointment, Patient and Treatment. The Appointment table is searched for
rows where the location of the appointment is 'clinic 1' and the appointment date is between 1st February and
28th February. The location of all affected rows is changed to 'clinic 9'. This part of the statement does not return
a table, it just changes the required data within the Appointment table.
The next part of the query searched the Appointment table for rows where the location of the appointment is
'clinic 9' and the appointment date is between 1st February and 28th February. The treatmentIDs of all matching
rows are returned. The Patient and Treatment tables are joined using patientIDs. Only those rows where the
treatmentID is in the set of treatmentIDs returned previously are displayed. Of those rows, only the first name,
surname and address are displayed. The results are ordered by the surname of the patient.
Output:
surname firstname
address
Robertson
Ryan
98 Norwich Road, New Costessey
Ross
Michael
99 Holt Road, Fakenham
Thomson Megan
High Street, Mulbarton
Watson Jennifer
The Cottage, Whitwell Street, Reepham
Williams Andrew The Pines, Patterson Road, Burnham Market
Young
Jordan
Hopfield lane
Fig 19. SQL query 9 output
7.10
Page 15 of 15
7.11
Page 16 of 16
Output:
7.12
firstname
surname
address
telno
Adam
Matthew
Amanda
Emily
Xavier
Samantha
Daniel
William
Nicole
Alexander
Ryan
Jose
Zachary
Zachary
Jacob
Timothy
John
Kyle
Zachary
Anderson
Brown
Campbell
Campbell
Cerveca
Clark
Gray
Jones
Morrison
Paterson
Robertson
Ross
Ross
Ross
Smith
Thomson
Walker
Wilson
Wilson
01263 748383
01263 878345
01263 548383
01263 548383
01263 748383
01463 848383
01263 848383
01508 748383
01603 848383
01263 548383
01263 865433
01953 648383
01953 648383
01953 648383
01353 448383
01263 448383
01553 548383
01263 748521
01263 748521
Show how many different nurses were working between 02/02/2006 and 04/02/2006?
SELECT COUNT(DISTINCT nurseID) AS nursesWorking
FROM shift
WHERE shiftdate BETWEEN '02/02/2006' AND '04/02/2006';
This query looks at the Shift table. The table is searched for all rows where the shift date is between 2nd
February and 4th February (2006). As some nurses may work more than one day between theses dates,
DISTINCT is used to return only a single occurrence of their nurseID for each nurse. The returned rows are
counted, and the result is displayed in a new table with a single column 'nursesWorking'.
Output:
nursesworking
40
Fig 22. SQL query 12 output
References
th
Connolly, T & Begg, C. (2005) Database Systems. 4 Ed. Harlow: Addison Wesley
The PostgreSQLQL Global Development Group, 2005, PostgreSQLQL 8.1.3 Documentation, Available from:
http://www.PostgreSQLql.org/docs/8.1/static/index.html [Accessed 6th April 2006]
Page 17 of 17
Page 18 of 18
Page 19 of 19
Sample Data
The following is a sample of data taken from the database tables
Employee
employeeid
firstname
surname
address
telno
jobtype
natinsno
dob
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
June
Amber
Jade
Mandy
Jill
Amy
Sue
Ann
Dot
Bev
Gail
Jane
Kim
Carol
Laura
Lyn
Liz
Susan
Helen
Sam
Barker
Barker
Corbett
Brown
Smith
Beven
Binks
Sim
Shipp
Shad
Santos
Sayer
Drake
Seago
Sewell
Skinner
Simkin
Skipper
Smart
Snow
Bath rd
exeter st
London rd
Deal way
The alley
Wick avenue
The links
The crescent
The backs
Beach rd
Sandy lane
Holt rd
High rd
Low rd
Back lane
The alley
Beach rd
The crescent
Bath rd
The alley
01263 982034
01263 102954
01219 034254
01263 129303
01263 983029
01263 981199
01263 987654
01263 222654
01229 183454
01263 293454
01293 487654
01263 438214
01263 123934
01263 103454
01381 432654
01238 391054
01263 982943
01229 987654
01263 203454
01374 283494
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
Nurse
HV293944E
KI209554E
FG493943E
FG453043K
FG439423L
FG453044K
FG455233H
FG455420E
FG455438E
FG455419E
FG452954E
FG455448E
FG451954E
FG458354E
FG194554E
FG455544E
FG450254E
FG494554E
FG455054E
FG452754E
02/02/1983
02/03/1979
02/02/1973
02/02/1985
02/05/1979
02/12/1983
02/11/1979
02/05/1982
02/02/1986
02/02/1977
02/10/1979
02/02/1982
02/11/1986
17/10/1979
02/10/1979
02/02/1980
02/02/1981
19/02/1979
02/02/1985
02/04/1977
Page 20 of 20
Doctor
Nurse
doctorid
gmcno
employeeid
nurseid
ukccpin
employeeid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
77882
748484
43327
3783
1034782
953302
11209
433901
478829
43929
588828
989231
1000932
772932
3923
492929
1303933
1049393
31
34
37
40
43
46
49
52
55
58
61
64
67
70
73
76
79
82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
23P112E
67P432A
32P864B
78P654C
12P349D
83P962E
10P842A
78P045B
61P951C
40P150D
70P942E
81P041F
92P432A
24P932B
32P627C
41P992D
50P220E
69P801F
78P471A
87P372B
32
33
35
36
38
39
41
42
44
45
47
48
50
51
53
54
56
57
59
60
Nursequal
Qualification
qualificationid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
qualification
Maternity
Paediatrics
General
Gynaecology
Cardiology
Orthopaedics
Urology
Respiratory
Renal
Oncology
Haematology
Endocinology
Dermatology
Neurology
Page 21 of 21
nurseid
qualificationid
1
2
3
4
5
6
6
7
8
11
12
12
12
15
16
16
23
24
25
26
27
1
2
8
1
2
2
7
4
4
5
13
9
5
6
6
10
1
1
2
2
4
Patient
patientid
firstname
surname
Michael
Smith
Christopher
Johnson
Jessica
Williams
Ashley
Jones
Matthew
Brown
Joshus
Wilson
Daniel
Thomson
David
Robertson
Amanda
Campbell
10
Andrew
Stewart
11
James
Anderson
12
Justin
Clark
13
Joseph
Ross
14
John
Walker
15
Ryan
Paterson
16
Robert
Young
17
Nicholas
Watson
18
Sarah
Morrison
19
Samantha
Gray
20
Stephanie
Smith
address
Flat 6C, Spitfire
Place, Norwich
22 Bill Todd Way,
Taverham
The Pines,
Patterson Road,
Burnham Market
3 Market Place,
Cawston
1 Quiddenham
Road, Attleborough
The Rectory,
Rectory Road,
Guestwick
High Street,
Mulbarton
98 Norwich Road,
New Costessey
1 Tickle Avenue,
Lourd
Fordham House,
Cheese Road,
Walsingham
2The Croft, Guist
154 Kingswood
Avenue, Thorpe
Marriott
99 Holt Road,
Fakenham
Old Bakery,
Queens Road,
Fakenham
78 Station Road,
North Elmham
Hopfield lane
The Cottage,
Whitwell Street,
Reepham
6B Phillips Road,
Lowestoft
16 The Street,
Somerton
Flat 6C, Spitfire
Place, Norwich
Page 22 of 22
telno
nhsno
dob
01353
448383
01328
448383
01263
648383
3927469256
24/01/2000
O+
1552039045
23/02/1999
A+
4688734660
18/03/1998
B+
01508
748383
01263
878345
01263
748521
176372888
17/04/1998
O+
4271403743
21/05/1999
A+
1569435502
22/06/1999
O-
01263
448383
01263
865433
01263
548383
01263
648383
5539338961
19/07/1998
O+
3961214123
08/08/1995
A+
5197177040
14/09/1997
A-
3588981421
15/09/1997
O+
01263
748383
01463
848383
9499804699
09/01/1996
A+
9695231260
04/10/1994
A-
01953
648383
01553
548383
8979483636
10/10/1996
O+
9622072702
06/11/1995
A+
01263
548383
01777
998826
01263
878383
489282484
07/12/1995
B+
7356543900
11/12/1996
O+
730919468
13/01/1997
A+
473365859
01/02/1937
O-
1039367003
04/03/1937
O+
9736605353
27/04/1943
A+
01603
848383
01263
848383
01353
448383
bloodtype
Treatment
treatmentid
notes
patientid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
4
8
7
6
9
3
1
2
5
3
1
2
3
4
5
6
7
8
9
10
Appointment
appointmentno
aptdate
apttime
location
doctorid
treatmentid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
02/01/2006
02/01/2006
02/01/2006
02/01/2006
03/01/2006
03/01/2006
03/01/2006
03/01/2006
04/01/2006
04/01/2006
04/01/2006
04/01/2006
05/01/2006
05/01/2006
05/01/2006
05/01/2006
06/01/2006
06/01/2006
06/01/2006
06/01/2006
10:00:00
12:00:00
14:00:00
16:00:00
10:00:00
12:00:00
14:00:00
16:00:00
10:00:00
12:00:00
14:00:00
16:00:00
10:00:00
12:00:00
14:00:00
16:00:00
10:00:00
12:00:00
14:00:00
16:00:00
clinic 1
clinic 2
clinic 3
clinic 4
clinic 5
clinic 1
clinic 2
clinic 3
clinic 4
clinic 5
clinic 1
clinic 2
clinic 3
clinic 4
clinic 5
clinic 1
clinic 2
clinic 3
clinic 4
clinic 5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
1
2
3
4
5
11
12
13
14
15
20
21
22
23
24
25
30
31
32
33
34
35
40
41
42
Page 23 of 23
Ward
Bed
wardid
wardname
floor
qualificationid
bedid
wardid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Barclay Ward
Blakeney Ward
Buxton Ward
Cley Ward
Coltishall Ward
Coronary Care Unit
Davidson Unit
Denton ward
Dilham Ward
Docking Ward
Dunston Ward
Earsham ward
Easton Ward
Edgefield Ward
Elsing Ward
Hethel Ward
Heydon Ward
Jack Pryor Unit
Mulbarton Ward
Rheumatology Day
Wd
G
1
2
G
1
2
G
1
2
G
1
2
G
1
2
G
1
2
G
1
3
1
2
4
3
5
3
6
3
3
13
3
3
3
12
9
10
3
11
3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3
4
4
4
4
4
InpatientStay
admittanceno
admitdate
admittime
discharge
dischargetime
doctorid
bedid
treatmentid
2
3
4
5
6
7
8
10
11
12
13
14
15
16
18
19
20
21
24/01/2006
24/01/2006
24/01/2006
25/01/2006
25/01/2006
25/01/2006
25/01/2006
26/01/2006
26/01/2006
26/01/2006
27/01/2006
27/01/2006
27/01/2006
27/01/2006
30/01/2006
30/01/2006
30/01/2006
31/01/2006
11:00:00
09:00:00
10:00:00
11:00:00
09:00:00
10:00:00
11:00:00
10:00:00
11:00:00
09:00:00
10:00:00
11:00:00
09:00:00
10:00:00
09:00:00
10:00:00
11:00:00
09:00:00
25/01/2006
25/01/2006
25/01/2006
26/01/2006
26/01/2006
26/01/2006
26/01/2006
27/01/2006
27/01/2006
27/01/2006
30/01/2006
30/01/2006
30/01/2006
30/01/2006
31/01/2006
31/01/2006
31/01/2006
01/02/2006
10:00:00
08:00:00
09:00:00
10:00:00
08:00:00
09:00:00
10:00:00
09:00:00
10:00:00
08:00:00
09:00:00
10:00:00
08:00:00
09:00:00
08:00:00
09:00:00
10:00:00
08:00:00
12
13
14
15
16
17
18
12
13
14
15
16
17
18
12
13
14
15
9
14
19
24
29
34
39
10
15
20
25
30
35
40
11
16
21
26
56
57
58
59
60
65
66
68
69
70
75
76
77
78
80
85
86
87
Page 24 of 24
Shift
shiftid
nurseid
shiftdate
shift
wardid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
01/01/2006
A
B
C
A
B
C
A
B
C
A
B
C
A
B
C
A
B
C
A
B
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
PatientNotes
notesid
1
notedate
05/09/2005
doctorid
3
treatmentid
212
06/12/2005
212
01/02/2006
15
213
01/02/2006
16
213
02/02/2006
16
213
04/02/2006
17
213
06/02/2006
16
213
11
06/02/2006
16
213
12
13/02/2006
213
13
07/03/2006
212
14
08/06/2006
213
doctorsnote
Referred by GP. Diagnosed with Type 2 Diabetes. Treatment
by diet and tables
Responding well to diet and medication treatment. Continue 3
monthly check ups
Admitted to A&E. Fell @ home. X-Ray confirmed fractured L
Neck of Femur. Admitted to Barclay Ward
Initial examination: Referred for emergency L hip
replacement. Analgesia prescribed
Hip replaced in theatre. Returned to ward and recovering well.
Strong analgesia prescribed
Transfer to chair. Commence physiotherapy. Analgesia
reduced to normal strength
Walking with zimmer frame. Transfer to Jack Prior Unit for
rehabilitation.
Wound healing well. Stable on feet with frame. Discharge
from ward. Referred to Fracture Clinic
Able to walk moderate distances with frame. Daily physio @
home with Community Physiotherapist
Diabetes uncontrolled by diet following hip operation. Now
Type 1. Commence insulin by injection
Wound healed. Excellent progress with frame - issued with
walking stick. Advised to use stick until confidence regained.
Discharged
Page 25 of 25
Page 26 of 26
Page 27 of 27
Fig 26. View 1 statement and output (For blood type B+)
Fig 27. View 2 statement and output (For blood type B+)
Page 28 of 28
Page 29 of 29
Treatment
Aliases
Staff
Occurrence
Employees are doctors and nurses who work within the
hospital
A doctor attends appointments at a given date and time
with patients. All patients are allocated a doctor from within
the hospital.
Nurses work on a shift system. Nurses are allocated to
wards based on their qualifications. Any nurse can work on
a general ward. A nurse needs a specific qualification to
work on a specialised ward.
Specialism A nurse must have a specific qualification to work on a
specialised ward.
The hospital provides care for in-patients and out-patients.
In-patients stay in the hospital. Out-patients attend
appointments.
Patients visit the hospital for treatment. A treatment
consists of appointments and in-patient stays.
Stay
Ward
Relationship
has
necessitates
works
t_requires
w_requires
allocated
attendedBy
assigned
locatedOn
d_isAn
n_isAn
worksOn
writes
writtenFor
Mult.
Entity
1..*
Treatment
0..* Appointment
0..*
Shift
0..* InPatientStay
0..1 Qualification
1..1
Doctor
1..1
Doctor
1..1
Bed
1..1
Ward
1..1
Employee
1..1
Employee
1..1
Ward
1..* PatientNotes
1..1
Treatment
Doctor
Nurse
nurseQual
Qualification
Patient
Appointment
Attribute
Description
EmployeeID
FirstName
Surname
Address
TelNo
jobType
NINo
DOB
DoctorID
GMCNo
EmployeeID
NurseID
UKCCPIN
EmployeeID
nurseID
qualificationID
qualificationID
qualification
PatientID
FirstName
Surname
Address
TelNo
NHSNo
DOB
bloodType
AppointmentNo Uniquely
date
identifies
appointment
Date of appointment
Time of appointment
Identifies patient attending the
appointment
Identifies the doctor attending
doctorID
the appointment
Location of appointment
Location
Identifies treatment for which
TreatmentID
appointment is needed
admittanceNo Uniquely identifies an in-patient
stay
Date at which patient to be
admitDate,
admitted
Time at which patient to be
admitTime,
admitted
dateDischarged, Date at which patient to be
discharged
timeDischarged Time at which patient to be
discharged
Identifies doctor allocated to
doctorID
patient
Identifies treatment for which intreatmentID
patient stay is needed
Identifies bed allocated for
bedID
patient stay
time
PatientID
InPatientStay
an
Page 31 of 31
Data type
Nulls?
Domains
int
varchar (10)
varchar (10)
varchar (50)
varchar (12)
varchar (10)
char (9)
N
N
N
N
Y
N
N
integer
string 1-10 long
string 1-10 long
string 1-50 long
string 1-12 long
string 1-10 long
string 9 long
Date
int
char (7)
int
int
char (8)
int
int
int
int
varchar (20)
int
varchar (15)
varchar (15)
varchar (50)
varchar (12)
char (10)
Date
char(3)
N
N
Y
N
N
Y
N
N
N
N
N
N
N
N
Y
Y
Y
Y
Y
int
Date
Time
int
N
N
01/01/2000
31/12/9999
00:00 23:59
integer
int
integer
varchar (10)
int
N
N
int
integer
Date
Time
01/01/2000
31/12/9999
00:00 23:59
Date
Time
01/01/2000
31/12/9999
00:00 23:59
int
integer
int
integer
int
integer
Attribute
Description
treatmentID
notes
patientID
Data type
Nulls?
Domains
N
Y
N
integer
string 1-100 long
integer
int
varchar (20)
char (1)
int
N
Y
Y
N
00-99
string 1-20 long
0-9
integer
int
int
N
N
integer
integer
int
int
N
N
integer
integer
Date
char(1)
int
N
N
01/01/2000
31/12/9999
single character
00-99
int
integer
Date
int
varchar (100)
Identifies patient associated with
int
Field for treatment notes
the treatment
Ward
Bed
shift
PatientNote
wardID
wardName
floor
qualificationID
bedID
wardID
shiftID
nurseID
date
shift
wardID
notesID
noteDate
doctorID
int
01/01/2000
31/12/9999
integer
treatmentID
int
integer
doctorsNote
varchar(200)
Page 32 of 32
Page 33 of 33