Sunteți pe pagina 1din 60

ACKNOWLEDGEMENT

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

What is a data model?.......................................................................................................6

1.2

Explain the advantages and disadvantages of data models, and discuss why relational

model is best fit for above scenario...........................................................................................11


1.3

Prepare a power point presentation to discuss the benefits and limitations of different

database technologies such as distributed database, data warehouse, etc.................................13


1.4

Analyze different approaches such as top-down approach, bottom-up approach in

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

Create Ward Table and Insert Data..................................................................................33

1.2

Create Nurse Table and Insert Data.................................................................................34

1.3

Create Patient Table and Insert Data...............................................................................35

1.4

Create Research Lab Table and Insert Data....................................................................36

1.5

Create Doctor Table and Insert Data...............................................................................37

1.6

Create Appointment Table and Insert Data.....................................................................38

1.7

Create Diagnosis Table and Insert Data..........................................................................39

1.8

Create Payments Table and Insert Data...........................................................................40

MAJOR SQL QUERIES...............................................................................................................41


Query 01.................................................................................................................................41
Query 02.................................................................................................................................42
Query - 03..................................................................................................................................43
Query 04.................................................................................................................................44
Query 10.................................................................................................................................45
Query 11.................................................................................................................................46
Query - 12..................................................................................................................................47
Query 13.................................................................................................................................48
Query 14.................................................................................................................................49
Query 15.................................................................................................................................50
Query 16.................................................................................................................................51
Query 17.................................................................................................................................52
4

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

A database based on the relational model developed by E.F. Codd. A relational


database allows the definition of data structures, storage and retrieval operations
and integrity constraints. In such a database the data and relations between them
are organized in tables. A table is a collection of records and each record in a table
contains the same fields.

Object-oriented models define a database as a collection of objects with features


and methods. A detailed discussion of object-oriented databases follows in an
Object-oriented

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

some advantages of the object-oriented model without its complexity


Object/relational database management systems (ORDBMSs) add new object

Model

storage capabilities to the relational systems at the core of modern information


systems. These new facilities integrate management of traditional fielded data,
complex objects such as time-series and geospatial data and diverse binary media
such as audio, video, images, and applets. By encapsulating methods with data
structures, an ORDBMS server can execute complex analytical and data
manipulation operations to search and transform multimedia and other complex
objects.
As an evolutionary technology, the object/relational (OR) approach has inherited
the robust transaction- and performance-management features of it s relational
ancestor and the flexibility of its object-oriented cousin.

Object-Oriented

Object DBMSs add database functionality to object programming languages. They

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.

In contrast to a relational DBMS where a complex data structure must be flattened


out to fit into tables or joined together from those tables to form the in-memory
structure, object DBMSs have no performance overhead to store or retrieve a web
or hierarchy of interrelated objects. This one-to-one mapping of object
programming language objects to database objects has two benefits over other
storage approaches: it provides higher performance management of objects, and it
enables better management of the complex interrelationships between objects.

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,

Disadvantages of data models


1. Increased Cost Data models require sophisticated hardware and software and
highly skilled personnel. The cost of maintaining the hardware, software, and
personnel required to operate and manage a Data modelscan be substantial.
Training, licensing, and regulation compliance costs are often overlooked when
Data modelsare implemented.
9

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

1.3Prepare a power point presentation to discuss the benefits and limitations


of different database technologies such as distributed database, data
warehouse, etc.
Distributed Databases
A distributed database is a database in which portions of the database are stored on multiple
computers within a network. Users have access to the portion of the database at their location
so that they can access the data relevant to their tasks without interfering with the work of
others.
Benefits of Distributed Databases
1. In a distributed database, data can be kept in different systems like personal computers,
servers, mainframes, etc.
2. A user doesnt know where the data is positioned physically. Database presents the data
to the user as if it were located locally.
3. Database can be gain access to over different networks.
4. Data can be combined and updated from different tables which are located on different
machines.
5. Even if a system be unsuccessful the reliability of the distributed database is sustained.
6. A distributed database is secure.
1.
2.
3.
4.
5.
6.

Limitations of Distributed Databases


Since the data is accessed from a remote system, performance is reduced.
Static SQL cannot be used.
Network traffic is increased in a distributed database.
Database optimization is difficult in a distributed database.
Different data formats are used in different systems.
Different DBMS products are used in different systems which increases in complexity of

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.

Benefits of Data Warehouses


Potential high returns on investment

Implementation of data warehousing by an organization entails a huge investment


characteristically from Rs 10 lack to 50 lacks. However, a study by the International Data
Corporation (IDC) in 1996 reported that average three-year returns on investment (RO I) in
data warehousing reached 401%.
2.

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.

Increased productivity of corporate decision-makers

Data warehousing recovers the productivity of corporate decision-makers by creating an


integrated database of consistent, subject-oriented, historical data. It participates data from
multiple mismatched systems into a form that delivers one consistent view of the
organization. By altering data into meaningful information, a data warehouse permits
business managers to perform more substantive, accurate, and consistent analysis.
4.

More cost-effective decision-making

Data warehousing assistances to reduce the overall cost of the product by dropping the
number of channels.

12

Limitations of Data Warehouses


1. Underestimation of resources of data loading
Sometimes we undervalue the time required to extract, clean, and load the data into the
warehouse. It may take the important proportion of the total development time, though some
tools are there which are used to decrease the time and effort spent on this process.
2. Hidden problems with source systems
Sometimes hidden .problems connected with the source systems feeding the data warehouse
may be recognized after years of being unnoticed. For example, when entering the details of
a new property, certain fields may allow nulls which may result in staff entering imperfect
property data, even when available and appropriate.
3. Required data not captured
In some cases the compulsory data is not taken by the source systems which may be very
essential for the data warehouse purpose. For example the date of registration for the stuff
may be not used in source system but it may be very important investigation purpose.
4. Increased end-user demands
After sustaining some of end-users queries, requests for support from staff may upturn rather
than decrease. This is produced by an increasing awareness of the users on the capabilities
and value of the data warehouse. Another reason for increasing demands is that once a data
warehouse is online, it is frequently the case that the number of users and queries increase
together with requests for answers to more and more compound queries.

13

1.4Analyze different approaches such as top-down approach, bottom-up


approach in database designing.
What is Database Design
Database design is the process of creating a complete data model of a database. This logical
datamodel covers all the wanted logical and physical design selections and physical storage
parameters required to produce a design in a Data Definition Language, which can then be used
to make a database. A completely attributed data model comprises descriptive attributes for every
entity.
The word database design could be used to detail many diverse steps of the design of a
complete database system. Principally, and most properly, it can be assumed of as the logical
design of the base data structures used to store the data. In the relational model these are
the tables and views. In an object database the entities and relationships map straight to object
classes and called relationships. However, the word database design can also be used to apply to
the overall process of designing, not just the base data structures, but similarly the forms and
queries used as portion of the complete database application inside the database management
system (DBMS).

Mainly there are two different approaches to database design they are,

1. Top-Down Method
2. Bottom-Up Method

14

Top-Down Method

Figure 1.4.1 Top-Down Method


A top-down method (also famous as stepwise design and in some cases used as a
synonym of decomposition) is basically the breaking down of a system to gain intuition
into its compositional ancillary -systems. In a top-down style a summary of the system is
formulated, identifying but not describing any first-level subsystems. Every subsystem is
then refined in so far greater detail, occasionally in many extra subsystem levels, till the
whole specification is decreased to base elements. A top-down model is frequently
specified with the help of "black boxes", these create it simple to manipulate. Though,
black boxes can fail to elucidate elementary mechanisms or be detailed sufficient to
accurately authenticate the model. Top down method begins with the large picture. It
breakdowns from there into smaller sections.

15

Bottom-Up Method

Figure 1.4.2 Bottom-Up Method


A bottom-up method is the patching together of systems to provide increase to more
difficult systems, thus creating the original systems sub-systems of the emergent system.
Bottom-up processing is a type of information processing based on received data from
the environment to form a conception. Information arrives the eyes in one way (input),
and is then turned into an image by the brain that can be converted and known as a
perception (output). In a bottom-up method the separate base elements of the system are
first identified in great detail. These elements are then connected together to form higher
subsystems, which then in turn are linked, occasionally in many levels, till a complete
top-level system is formed. This policy frequently resembles a "seed" model, whereby the
commencements are small but ultimately grow in difficulty and fullness. Though,
"organic strategies" can result in a tangle of elements plus subsystems, developed in
separation and issue to local optimization as opposite to meeting a global resolution.
16

CONCEPTUAL DIAGRAM

Figure: Conceptual Diagram - Context Diagram


17

DESIGN REQUIREMENTS AND ASSUMPTIONS


This scenario is about a hospital database system. This system focused on some basic
requirements as mentioned follow.
i. There are two type of doctor named Practitioners and Researchers. Both
have a unique ID number. All the Hospitaldetails of both the types are
saved in the database. Practitioners re seeing patients while Researchers
are working on the research labs located at the hospital. Basically
researches are working on three major fields Cancer, Cardiology, and
Gynecology.
ii. Patients details also recorded in a database table named Patient. They
also have a unique ID number. There are two types of patients Admitted
and none admitted.
iii. Admitted patients are assigned to a nurse, ward and a room number.
iv. There are four main wards in this hospital named W1, W2, W3 and W4.
Each ward has a floor number and a head nurse.
v. Many nurses are working in a ward. A nurse can assigned only for a one
patient at a time. Nurses work only on the ward they are allocated.
vi. Every patient have to get an appointment to meet a doctor. Those
appointment details are recorded by a secretary. Each appointment has a
unique ID number.
vii. Payments for all those appointments are recorded only if the appointment
is completed. Mode of payment can be cash payments or credit-card
payments.
viii. Doctor is recording a diagnosis after seeing patient. The diagnosis records
are also saved in the database.

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

Figure: Functional dependency


There are three types of functional dependencies. They are:
1. Full Functional Dependency
2. Partial Functional Dependency
3. Transitive Dependency
Full Functional dependency
The major requirement for full functional dependency is that minimum number of
attributes necessary to maintain the functional dependency with the attributes on the right
hand side. The set of attributes on the left hand side of the functional dependency
statement cannot be reduced any further. If the entity relationship diagram is completed
all the three normal forms then that diagram should have only this type of dependencies.
Other two types of functional dependencies cannot be remain in a fully normalized ERD.

21

All the entities in the ER diagram include in this assignment contains only full functional
dependencies.

Figure: Full functional dependency in the Payment Table

Payment ID

Payment Mode

Figure: Dependency of payment table

22

Payment mode is fully dependent on Payment ID.

23

Partial Functional Dependency


A partial dependency occurs when an attribute is dependent only partially on the primary
key as opposed to the primary key in its entirety. In this case, the primary key is becomes
a composite key. Partial dependency will violate the second normal form in
normalization. So this type of dependency should remove. For that purpose separate
tables will be needed. As an example when considering about three attributes named A, B
and C, and if C is dependent on A and B that simply means that there is the partial
dependency. These type of dependency should remove to have a proper normalized table.

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

Figure: Process of Normalization (Lecturer Slides)

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.

Figure: First Normal form

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.

Figure: Second normal form

27

All the attributes shown in the above Doctor table is fully dependent on doctor ID which
is the primary key of that table.

Third Normal Form


A relation that is in first and second normal form and in which no non-primary key
attribute is transitively dependent on any candidate key. Third normal form based on
transitive dependency. All the transitive dependencies are removed in this hospital
database system by the author. So that has completed all the three normal forms.
In this scenario it describes a direct relationship between Doctor and Patient. It says that
Doctor can have many patient and Patient can have many doctors. The relationship
between these two entities are many to many. Many-to-many relationship will occur data
redundancy. So that many to many relationship should be removed. For that purpose
author has connected Appointment table with both of these tables.

Doctor

Patient

Appointment

Figure: Third normal form

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.

Entity Integrity constraints


Referential Integrity constraints

Entity Integrity constraints


This integrity is based on primary key. Primary key is a candidate key which we can used
to uniquely identify the tuple/row with in an entity. Entity Integrity explains that any
component/attribute of the primary key of a base relation is not allowed to accept null
values. Though alternate keys can be null, primary key cannot be null in any case as it
refers to a unique value in the entity.
The entity relationship diagram designed by the author for this scenariodoes not contain
any null values for primary key in any entity. Entity integrity rule is applied for all the
entities designed for the hospital database system. Each entity have a primary key to
uniquely identify the rows which is not null in any case.

29

Table: Entity Integrity constraints


Entity
Patient
Doctor
Appointment
Nurse
Diagnosis
Payment
Research lab
Ward

Primary Key
patient ID
doctor ID
appointment No
nurse ID
diagnosis ID
payment ID
lab ID
ward No

30

P001, P002, P003


D001, D002, D003
APP001, APP002, APP003
NS001, NS002, NS003.
DG001, DG002, DG003
001PD. 002PD, 003PD
Lab01, Lab02, Lab03
W1, W2, W3, W4

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.

CREATE AND INSERT TABLE STATEMENTS


1.1

Create Ward Table and Insert Data

32

Figure: Insert data into ward SQL statement

33

1.2

Create Nurse Table and Insert Data

Figure: Create Nurse Table SQL statement

Figure: Insert data into Nurse SQL statement

34

1.3

Create Patient Table and Insert Data

Figure: Create Patient Table SQL statement

Figure: Insert data into Patient SQL statement

35

1.4

Create Research Lab Table and Insert Data

Figure: Create Research Lab SQL statement

Figure: Insert data into Research Lab SQL statement

36

1.5

Create Doctor Table and Insert Data

Figure: Create Doctor Table SQL statement

Figure: Insert data into Doctor SQL statement

37

1.6

Create Appointment Table and Insert Data

Figure: Create Appointment Table SQL statement

Figure: Insert data into Appointment SQL statement

38

1.7

Create Diagnosis Table and Insert Data

Figure: Create Diagnosis Table SQL statement

Figure: Insert data into Diagnosis SQL statement

39

1.8

Create Payments Table and Insert Data

Figure: Create Payment Table SQL statement

Figure: Insert data into payment SQL statement

40

MAJORSQL QUERIES
Query 01

List the details of all the patients who live in Colombo

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

Author has made an assumption that 2015 03- 01 is Today.

Query 04
List the contact number of patient Tom Cruise who has made an appointment
tomorrow

This query is based on two table. Those two tables are:


Appointment table
Patient table
While doing this database assignment based on SQL queries, author has made an
assumption that tomorrow is considered as 2015 03- 10.

44

Query 10

List the names of all the patients diagnosed to have Cancer, in ascending order of
patient ID

This query is based on three tables. They are:


Diagnosis table
Appointment table
Patient table

45

Query 11

C
o
u
nt

the number of nurses working on each ward

46

47

Query - 12

List names of all the nurses who are attending to patients on ward W1

This query based on two tables. They are:


Patient table
Nurse table

48

Query 13

Find the maximum payment made by a patient, and the mode of payment

49

Query 14

How many male patient is currently admitted in the hospital

50

Query 15

List the names and ward number of nurses who are not assisting any admitted patients

This query is based on two tables. They are:


Patient table
Nurse table

51

Query 16

List the doctor ID and name of the doctors who have diagnosed a Cancer for patients

This query is based on three tables. They are:


Diagnosis table
Appointment table
Doctor table

52

Query 17

Del
ete
the

name whose name is Miley Cyrus

53

54

Query - 18

Find the names of the patient who are admitted in ward W1 and live in Negombo

This query is based on two tables. They are:


Patient table
Nurse table
Author has used a Join query in here.

55

Query 19

Count the number of appointments made by each patient

56

Author has used one table Appointment table- to get data to execute this query.

57

LIMITATIONS AND IMPROVEMENTS


There are some limitation in this hospital systems and there are some improvements that
are to be done. Some major limitations in this database system are:
I.

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.

unimplemented database system.


Admitted patient history is not saved in any database table in this
system. Those details can be useful later. So this is another limitation

III.

in this system.
There must be a person who is responsible for managing payments
other than the secretary.

To avoid those limitations mentioned above we have to focus on some system


improvements. Implementing user interfaces, creating another database table to store
admitted patient history, having an entity named cashier to manage payment details are
some improvements that can be done to improve this hospital database system.

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-

insider.com/portfolio/benefits-of-a-data-warehouse/ [Accessed on 16 February 2016].


2. Robert Rees ( 2015). An intro to NoSQL databases. [Online] Available at:

http://www.thoughtworks.com/insights/articles/nosql-comparison [Accessed on 6
February 2016].
3. Anon ( n.d.). Relational Data Model [Online] Available at:

http://infolab.stanford.edu/~ullman/focs/ch08.pdf [Accessed on 6 February 2016].


4. Burleson Consulting (2016). Object Database Design [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

Warehousing[Online] Available at: http://www.differencebetween.info/differencebetween-data-mining-and-data-warehousing [Accessed on 16 February 2016].


6. Techopedia(2016). Relational Model. [Online] Available at:

http://www.techopedia.com/definition/24559/relational-model-database [Accessed on 6
February 2016].

60

S-ar putea să vă placă și