Database - Hospital
Database - Hospital
Database - Hospital
I would like to convey my heartiest gratitude to all the people who were helped me to conclude
this assignment in successfully.
I take this opportunity to thank for our dear lecturer of Data Analysis and Design, my
lecturersguidance for us since at the beginning of this project with providing the necessary
information and empowered our knowledge by teaching various kinds of Data analysis and
designing technologies. Thank you very much dear sir for your unforgettable help to conclude
this project successful mode.
I would further thankful to my beloved parents for their invaluable and immeasurable dedication
and unforgettable help for succeeded this project.
Thank you!
INTRODUCTION
Hospital Health Record System of a person is mainly can manage from a Hospital. The
reason is in a Hospital System the Hospital Health records are stored properly. Therefore,
assuming the XYZ Hospital system which is interconnected or linked with Hospital
Health Records is mainly based on Database systems. This database stores details
aboutthe Hospital Health Record such as Doctor and Nurses who work in the hospital,
details of the patient who come to see doctors, details about admitted patients, details of
the appointments and the payments that are made by the patients, and details of diagnosis
recorded by doctors about each patient. This can be either consider as one particular
person or set or patients in the hospital.
Doctors are in two types named Practitioners and Researchers. Researchers are working
on research labs while practitioners see the patients. Research labs have three main fields
called Cancer, Cardiology and Gynecology. Practitioners can see many patients. Patients
also can meet any number of doctors.
There are two type of patients admitted and non-admitted. Each patient have to get an
appointment to see a doctor. Admitted patient are assigned to a ward, room and nurse.
There are four wards. Each ward has more than one nurse working in it. One head nurse
out of all the nurses will manage each ward.
Payment are recorded only when the appointment is completed. Payments and Appointment
details are recorded by a secretary. Doctor record the diagnosis after seeing the patient. Each
appointment have a diagnosis made by a doctor about the patient. Each entity related to this
hospital system has primary key to identify them uniquely.
Table of Contents
INTRODUCTION...........................................................................................................................2
Task 1...............................................................................................................................................6
1.1
1.2
Explain the advantages and disadvantages of data models, and discuss why relational
Prepare a power point presentation to discuss the benefits and limitations of different
database designing.....................................................................................................................16
CONCEPTUAL DIAGRAM.........................................................................................................19
DESIGN REQUIREMENTS AND ASSUMPTIONS...................................................................20
ER DIAGRAM..............................................................................................................................22
FUNCTIONAL DEPENDENCIES...............................................................................................23
NORMALIZED TABLES.............................................................................................................26
INTEGRITY CONSTRAINTS......................................................................................................30
CREATE AND INSERT TABLE STATEMENTS........................................................................32
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
Query - 18..................................................................................................................................53
Query 19.................................................................................................................................54
LIMITATIONS AND IMPROVEMENTS....................................................................................55
CONCLUSION..............................................................................................................................56
References......................................................................................................................................57
Task 1
1.1 What is a data model?
A data model is a set of theories that can be used to describe the structure of database. Data
models can be divided into 3 main categories
1. High level or Conceptual data models: - these are based on entities and relationships.
They provide concepts that are near to the way of many users who perceive data.
2. Low level or Physical data models: - they provide concepts that describe the details of
how data will store in the computer. These concepts are mean for the computer Engineers
not for the typical users or end users.
3. Representational or Implementational data models: - concepts which provide by these
data models can be understood by the end users. These
hide some parts of data storage but can be applied on a computer
system directly.
Present aspects that can be comprehended with the user however, not too much on the approach
info will be stored from the laptop or computer. Three well-known info models of this manner
are usually relational info style, system info style along with hierarchical info style.
Common reasonable info types intended for databases consist
Hierarchical database model
Network model
Relational model
Entityrelationship model
Enhanced entityrelationship model
Object model
Document mode
Entityattributevalue model
Star schema
1.
Hierarchical Model
The hierarchical data model organizes data in a tree structure. There is a hierarchy
of parent and child data segments. This structure implies that a record can have
repeating information, generally in the child data segments.
For example, books could be broken up into fiction and non-fiction. Each of these
categories can be broken up into subcategories. They can continue like this by
listing individual authors and then the individual book titles.
Network Model
For example, books could be broken up into fiction and non-fiction. Each of these
categories can be broken up into subcategories. They can continue like this by
listing individual authors and then the individual book titles .The popularity of the
network data model coincided with the popularity of the hierarchical data model.
Some data were more naturally modeled with more than one parent per child. the
Conference on Data Systems Languages formally defined the network model. The
basic data modeling construct in the network model is the set construct. A set
consists of an owner record type, a set name, and a member record type.
Relational Model
advanced module.
Model
Object-oriented models are very powerful but also quite complex. With the
.
relatively new object-relational database model is the wide spread and simple
relational database model extended by some basic object-oriented concepts. These
allow us to work with the widely known relational database model but also have
Object/Relational
Model
Object-Oriented
Model
bring much more than persistent storage of programming language objects. Object
DBMSs extend the semantics of the C++, Smalltalk and Java object programming
languages to provide full-featured database programming capability, while
retaining native language compatibility. A major benefit of this approach is the
unification of the application and database development into a seamless data
model and language environment. As a result, applications require less code, use
more natural data modeling, and code bases are easier to maintain. Object
developers can write complete database applications with a modest amount of
additional effort.
1.2 Explain the advantages and disadvantages of data models, and discuss why relational
model is best fit for above scenario.
Advantages of data models
1. High quality - we should consider data before building an app. On average, about
70 percent of software development efforts fail, and a major source of failure is
premature coding. A data model helps define the problem, enabling us to consider
different approaches and choose the best one
2. Reduced cost - we can build applications at lower cost via data models. Data
modeling typically consumes less than 10 percent of a project budget, and can
reduce the 70 percent of budget that is typically devoted to programming. Data
modeling catches errors and oversights early, when they are easy to fix
3. Clearer scope - A data model provides a focus for determining scope. It provides
something tangible to help business sponsors and developers agree over precisely
what is included with the software and what is omitted. Business staff can see what
the developers are building and compare it with their understanding.
4. Faster performance - A sound model simplifies database tuning. A well-constructed
database typically runs fast, often quicker than expected. To achieve optimal
performance, the concepts in a data model must be crisp and coherent
5. Fewer application errors - A data model causes participants to crisply define
concepts and resolve confusion. As a result, application development starts with a
clear vision. Developers can still make detailed errors as they write application code,
2. System complexity - In a network model, data are accessed one record at a time. This males it
essential for thedatabase designers, administrators, and programmers to be familiar with the
internal datastructures to gain access to the data. Therefore, a user friendly database management
systemcannot be created using the network model
3. Lack of structural independence - Making structural modifications to the database is very
difficult in the network database modelas the data access method is navigational. Any changes
made to the database structure require theapplication programs to be modified before they can
access data.
According to the comparison and given Scenario when data model implementation phase comes
relational data model suitable for handle information about the XYZ hospital since the problem
statement justifies that the data dependency can be seen so relational data model comes with
relationship feature using that we can hold dependent information consistently. And many more
advantages can be seen in relational data models such as,
1. Ease of use: The revision of any information as tables containing of rows and columns is
much easier to recognize.
2. Flexibility: Dissimilar tables from which information has to be connected and mined can
be easily manipulated by operators such as project and join to give information in the
form in which it is wanted.
3. Precision: The practice of relational algebra and relational calculus in the handling of the
relations between the tables ensures that there is no uncertainty, which may otherwise
arise in establishing the linkages in a complicated network type database.
4. Security: Security control and approval can also be applied more easily by moving
sensitive attributes in a given table into a separate relation with its own authorization
controls. If authorization requirement licenses, a particular attribute could be joined back
with others to enable full information retrieval.
5. Data Independence: Data independence is achieved more easily with normalization
structure used in a relational database than in the more complicated tree or network
structure.
10
the system.
7. Managing system catalog is a difficult task.
11
8.
Data Warehouse
In computing, a data warehouse (DW or DWH), also recognized as an enterprise data
warehouse (EDW), and is a system used for reporting and data analysis. DWs are dominant
repositories of integrated data from one or more dissimilar sources.
1.
Competitive advantage
The huge returns on speculation for those companies that have successfully implemented a
data warehouse is evidence of the enormous competitive advantage that accompanies this
technology. The competitive advantage is grown by allowing decision-makers access to data
that can reveal previously unavailable, unknown, and unused information on, for example,
customers, trends, and demands.
3.
Data warehousing assistances to reduce the overall cost of the product by dropping the
number of channels.
12
13
Mainly there are two different approaches to database design they are,
1. Top-Down Method
2. Bottom-Up Method
14
Top-Down Method
15
Bottom-Up Method
CONCEPTUAL DIAGRAM
18
Assumption made:
i. Doctors, Patients, Nurses, Appointments, Payments and Diagnosis have
unique ID numbers.
ii. All the details of Doctors, Nurses, Research labs and Wards are entered to
the system by a system administrator. Details of Patient, Appointment and
payments are recorded by a secretary. Doctors record only diagnosis
details.
iii. Researchers and Practitioners details are saved in one database table called
Doctor. It has an attribute named type which store the type of the doctor.
And also that table contains an attribute called lab ID which stores a lab
ID only if that Doctor is a researcher. Lab ID column in the database table
can be NULL.
iv. There are six research labs named Lab01, Lab02, Lab 03, Lab04, Lab05
and Lab06. Lab01 and Lab02 is for Cancer researchers. Lab03 and Lab04
is for Cardiology researchers while other two labs are for Gynecology
researchers. All the lab have at least one researchers working on.
v. Patients are two types called admitted and normal. Patient database table
have a column named patient type. It records the type of the patient as
admitted or normal.That table also consist of two columns called
nurse ID and room no. Those two columns can be NULL. It contains a
value only if that patient is admitted.
vi. Four ward are located in four floors.
vii. Each nurse has a ward to work. And also each ward has at least one nurse.
There are no ward not having a nurse.
viii. Patient can get any number of appointments to see any doctor.
19
ER DIAGRAM
Figure: ER Diagram
20
FUNCTIONAL DEPENDENCIES
The concept of functional dependency is introduced by professor Codd in 1970 when he
defined the first three normal forms. Functional dependency is the most important part in
the normalizations. It describes the relationship between attributes in an entity.
B is functionally dependent on A
21
All the entities in the ER diagram include in this assignment contains only full functional
dependencies.
Payment ID
Payment Mode
22
23
Transitive Dependency
Third normal form based on this type of functional dependency. In third normal form all
the transitive dependencies will be removed. It is important to recognize a transitive
dependency as its existence a relation can potentially cause update anomalies.
As an example consider about three attributes named A, B and C. If B is dependent on A
and C is dependent on, then C is said to be transitive dependent on A via B.
24
NORMALIZED TABLES
Normalization is the process of reorganizing data in a database so that data redundancy (data
duplication no repeated data in the database) will not occur. And normalization will a cause
for logical data dependency which simply describes that all the data are stored together in a
one place.
25
There are major three normalization steps should follow to get a fully normalized database
table. They are:
1. First normal form
2. Second Normal form
3. Third normal from
First Normal Form
First normal form describes that there should not have any repeating data values in database
table which simply means that intersection of each row and column contains only one value.
When an entity completes its first normal form, having a primary key is compulsory thing
and important point.
When considering the Appointment table and Patient table in this hospital database system,
patient ID is included in the appointment table as a foreign key. It is showed in the following
figure.
26
We can do this opposite way also by including app No in the patient table as a foreign
key. But it will be a reason for data repeating in patient table because one patient can any
number of appointments. Patient table primary key will be repeated.
Table: First normal form example
Patient ID
P001
P002
P003
P001
P002
Appointment No
APP001
APP002
APP003
APP004
APP005
Because of this problem author has included patient ID in the Appointment table.
Second Normal Form
This normal form based on full functional dependency. All the entities are completed
second normal form in this hospital database system. That simply explains that there are
no partial dependencies in any table, only full dependency remains.
27
All the attributes shown in the above Doctor table is fully dependent on doctor ID which
is the primary key of that table.
Doctor
Patient
Appointment
As you can see in the above figure Doctor and Patient relationship no more contains when
Appointment table comes to the picture. This is because Doctor can access patient details via
28
Appointment table. And also patient can get the details of doctors via appointment. This explains
how the transitive dependencies are removed in third normal form.
INTEGRITY CONSTRAINTS
Integrity constraints are a set of data validation rules that you can specify in order to
restrict the data values that can be stored for a variable in a SAS data file. Integrity
constraints help you preserve the validity and consistency of your data. SAS enforces the
integrity constraints when the values associated with a variable are added, updated, or
deleted.(Support.sas.com-2015)
Integrity constraints simply means rules which we should follow when working with the
database. Specific integrity rules apply to one specific database. There are two major
general integrity rules whichcan apply to all the databases.They are:
I.
II.
29
Primary Key
patient ID
doctor ID
appointment No
nurse ID
diagnosis ID
payment ID
lab ID
ward No
30
Referential Integrity
Referential integrity is based on foreign key in an entity. Foreign Key is an attribute or set
of attributes within one relation that matches candidate key of some relation. Foreign
keys can hold null values. But if they are not null they should hold a value that isexisting
as a primary key in another table. It simply describes that every non-null foreign key
value must reference an existing primary key value.
Figure:Referential Integrity
Some of entities in this database system contains foreign with null values.
31
Doctor table in this scenario contains a foreign key attribute/columns with null values.
Lab ID is a foreign key from Research lab table. It can contains a null value for
practitioners. This is a perfect example for foreign key with null values. Also this
describes referential integrity which means that all the foreign key values included in the
lab ID column, match with the primary key values in the Research lab table.
32
33
1.2
34
1.3
35
1.4
36
1.5
37
1.6
38
1.7
39
1.8
40
MAJORSQL QUERIES
Query 01
Query 02
List details of all the male doctors whose last name is Silva
41
42
Query - 03
List all the appointments scheduled for tomorrow
43
Query 04
List the contact number of patient Tom Cruise who has made an appointment
tomorrow
44
Query 10
List the names of all the patients diagnosed to have Cancer, in ascending order of
patient ID
45
Query 11
C
o
u
nt
46
47
Query - 12
List names of all the nurses who are attending to patients on ward W1
48
Query 13
Find the maximum payment made by a patient, and the mode of payment
49
Query 14
50
Query 15
List the names and ward number of nurses who are not assisting any admitted patients
51
Query 16
List the doctor ID and name of the doctors who have diagnosed a Cancer for patients
52
Query 17
Del
ete
the
53
54
Query - 18
Find the names of the patient who are admitted in ward W1 and live in Negombo
55
Query 19
56
Author has used one table Appointment table- to get data to execute this query.
57
There are no user interface to interact with the users. Data are entered
directly to the system by users. This is main limitations in this
II.
III.
in this system.
There must be a person who is responsible for managing payments
other than the secretary.
58
CONCLUSION
Database of XYZ Hospital service is now completed. Newly implemented database for XYZ
Hospital service meets all the requirements of the company which they have expected from the
system and it is fully functional without making errors.
In the designing stage of the database, relational model has been selected to model the database
after comparing other data models. Proper justifications have been provided with the document
for selecting relational model. Then the entity relationship Diagram and mapping algorithm has
been provided with the documentation in order to understand the relationships among entities
and mapping of conceptual data models with relational database schema.
Also, the document consists with different database approach techniques and the designing is
done by using top down database designing approach. Proper justifications have been provided
with the document for selecting top down approach. After that, provided a proper quality plan for
the project and explained how it helped to ensure product meets its specifications.
The database is created after analyzing the requirements of the company and effectively the
queries has been constructed according to the requirements. All the tables of the database have
been normalized up to 3rd normal form and examples are provided with the documentation.
Appropriate data types and field sizes have been used to build an effective database. Procedures
have been used to make it easy to use the database for the users. All the queries used in this
database are fully optimized. Also this document consist a complete user manual for intended
users to manage the database. Data validation and verification techniques are used with this
database and this document shows how these techniques are implemented with the system with
proper examples.
The database is tested well by conducting tests to all aspects of the database. Proper reports have
been generated using SQL server business intelligence studio in order to support company
management to make decisions. Finally, this newly build database designed correctly. Company
can meet the entire requirement that they needed.
59
References
1. Bi-Insider (2011). Benefits of a Data Warehouse. [Online] Available at: http://bi-
http://www.thoughtworks.com/insights/articles/nosql-comparison [Accessed on 6
February 2016].
3. Anon ( n.d.). Relational Data Model [Online] Available at:
http://www.dba-oracle.com/t_object_top_down_bottom_up.htm [Accessed on 16
February 2016].
5. Difference Between(2016). Difference Between Data Mining and Data
http://www.techopedia.com/definition/24559/relational-model-database [Accessed on 6
February 2016].
60