Top Banner
Database Design HIMA 4160 Fall 2009
56

Database Design HIMA 4160 Fall 2009. House Keeping Assignment 4 due tonight Assignment 5 due next Monday.

Dec 23, 2015

Download

Documents

Coral Lee
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Database DesignHIMA 4160

Fall 2009

Page 2: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

House Keeping Assignment 4 due tonight Assignment 5 due next Monday.

Page 3: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Agenda Database Concepts Entity Relational Diagram (ERD)

Page 4: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Database == Data + Base

Transaction Storage

Page 5: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Database: Definition A collection of data that:

is organized usually computer-based represents repetitive information implicitly primarily for transaction supports retrieval

Page 6: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Is paper medical record a database? Yes No No opinion

Page 7: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Is Excel a database system? Yes No No Opinion

Page 8: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

The shortcomings of a large table

Patient_ID Patient_Name…

Doctor_ID Doctor_Name …

1 Patient B … 1 Doctor A …

2 Patient C … 1 Doctor A …

3 Patient D … 1 Doctor A …

4 Patient E … 2 Doctor B …

5 Patient F … 2 Doctor B …

6 Patient G … 2 Doctor B …

7 Patient H … 2 Doctor B …

8 Patient I … 2 Doctor B …

Page 9: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

A more relational database

Patient ID Patient

1 Patient A

2 Patient B

3 Patient C

4 Patient D

Doctor ID Doctor

1 Doctor A

2 Doctor B

3 Doctor C

4 Doctor DPatient ID Doctor ID

1 2

1 3

2 1

4 1

3 3

1 4

Page 10: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Database Management System (DBMS) A computer program for the purposes of

managing databases. Is the basis for many applications (e.g.,

Electronic Health Records, Personal Health Records).

A DBMS can host many databases A database can be implemented in many

different DBMS systems.

Page 11: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Data Modeling Before you implement a database, you need

to design the database Data modeling is a systematic way to help you

design the database. Map/simplify the real world to database

schema/structure.

Page 12: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Data Modeling

Page 13: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Why Data Modeling? Power and flexibility of database depend on

data model

Database is the realization of data model

Evaluation of commercial products

Communicating with vendors and IT staff

Building your own databases

Page 14: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Database Analysis Determine User Requirements Develop Data Models “A conceptual data model is one that

represents data from the viewpoint of the user, independent of any technology that will be used to implement the model.”

A database has two parts Schema Data

Page 15: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Stages of Data Modeling Conceptual Model

E-R diagram Logical Model

Relational Model Physical Model

Database management

Page 16: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Database Modeling

Real World

E-RDiagram

RelationalModel DBMS

Conceptual Logical Physical

Page 17: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Introduction Entity Relationship Modelling (ERM)

A technique used to analyze & model the data in organizations

Using diagram to represent entities and relationship of components in a system.

Supported by modern DBMS system. De facto tool for database design

Page 18: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

The Importance of Data Modeling Characteristics captured during data

modeling crucial in design of databases, programs, other

items facts and rules essential in assuring data

integrity Data are the most complex aspects of the

modern organization Data are determined by the business rules. Need to avoid scope creeps

Data tend to be more stable than the business processes that use the data

Page 19: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.
Page 20: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Definitions Entity

an aggregation of a number of data elements each data element is an attribute of the entity

Relationship an association between two or more entities

that is of particular interest

Page 21: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Background Introduced by Peter Chen in ’75

“The Entity-Relationship Model – Toward a Unified View of Data”, ACM Transactions on Database Systems, Vol. 1, No. 1, March 1976, Pages 9 - 36

now widely used in commercial database.

Page 22: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Why use ER Diagrams ? provides a global quick reference to an

organization’s data structures. can be used individually to design an

Information System’s (IS) data structure. offers a basis of consequential database

design and development.

Page 23: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

ERD Development Process Identify the entities Determine the attributes for each entity Select the identifier for each entity Establish the relationships between the

entities Draw an entity model Test the relationships and the keys

Page 24: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Entities

Person, place, object, event, or concept … in the user environment about which the organization wishes to maintain

data Entity type

collection of entities that share common properties or characteristics

CAPITAL LETTERS Entity instance

single occurrence of an entity type ENTITY

Page 25: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

A Simple Example

STUDENTs attend COURSEs that consist of many SUBJECTs.

A single SUBJECT (i.e. English) can be studied in many different COURSEs.

Each STUDENT may only attend one COURSE.

Page 26: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Identify the entities

Any physical object, event, or abstract concept that we can record facts about.

Rule of thumbs:a.Look for nounsb.Not all nouns are entitiesc.Some of them are attributes

Page 27: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Identify EntitiesA football team has coaches, players, trainers and other assistants. Coach’s roles include head coach, defense and offence coordinators, quarterback coaches, etc. Football players can play different positions like quarterback, running backs, receivers etc.

Rule of thumbs:

a.Look for nouns

b.Not all nouns are entities

c.Some of them are attributes

Page 28: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Identify Entities (my answers) Coach Player Trainer Assistants Roles Positions

Page 29: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Attributes Property or characteristic of an entity type

that is of interest to the organization initial capital letter followed by lowercase letters underscore instead of space (first_name)

Simple or Composite? composite has component parts will users need to refer to those individual

components? Single-valued or Multivalued? Stored or Derived?

PLAYER

Name Number

Page 30: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Determine the Attributes Every Entity has attributes. Attributes are characteristics that allow us

to classify/describe an entity e.g., entity STUDENT has the attributes:

student numbernamedate of birth course number

Page 31: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Identifier [Attribute] “An identifier is an attribute (or

combination of attributes) that uniquely identifies individual instances of an entity type.” atomic or composite

Criteria will not change its value never null unique

PLAYER

Name Number

SS#

Page 32: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Key Attributes Certain attributes identify particular facts

within an entity, these are known as KEY attributes.

The different types of KEY attribute are: Primary Key

Composite Primary Key Foreign Key

Page 33: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Key Definitions

Primary Key: One attribute whose value can uniquely

identify a complete record (one row of data) within an entity.

Composite Primary Key A primary key that consists of two or more

attribute within an entity. Foreign Key

A copy of a primary key that exists in another entity for the purpose of forming a relationship between the entities involved.

Page 34: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

ER Diagram Notations

Every entity diagram consists of the following components:

COURSECOURSEEntity (labelled box)

Relationship line

Page 35: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Degrees of a Relationship

MANMAN WOMANWOMAN

CUSTOMERCUSTOMER ORDERORDER

COURSECOURSE SUBJECTSUBJECT

One-to-one (1:1)

One-to-many (1:n)

Many-to-many (n:m)

NOTE: Every many to many relationship consists of two one to many relationships working in opposite directions

1 M

1 1

M M

Page 36: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

MANMAN WOMANWOMAN

CUSTOMERCUSTOMER ORDERORDER

CourseCourse SubjectSubject

One-to-one (1:1)

One-to-many (1:n)

Many-to-many (n:m)

Notation of Cordiality (Degree of relationship)

Page 37: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

A person can own no or several cars. A car doesn’t have to be owned by a person, but if it is, it is owned by only one person.

Notation for Optional Participation

CARPERSON

optional relationship

1 M

1

Page 38: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

A Sample Four Entities ER Diagram

A Student Record Entity DiagramA Student Record Entity Diagram

Page 39: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Exercise One patient can see several doctors. One

doctors can see many patients. A patient may not see a doctor at all

Page 40: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Exercise A nurse is assigned to manage an exam room.

Page 41: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Exercise A patient must have a insurance and a

insurance company can have many patients as their customer.

Page 42: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Exercise (complex one) Draw an E-R diagram to represent the data

schema of a physician office. The entities included are physicians, patients, insurance companies, lab, medications etc.

Page 43: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

ER Diagram SummaryIdentify the entities

Determine the attributes for each entity

Select the primary key for each entity

Establish the relationships between the entities

Draw an entity model

Page 44: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Logic Design and Physical Design

Page 45: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Conceptual Design

BED PATIENTS

Page 46: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Conceptual Design

DOCTORS PATIENTS

Page 47: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

DOCTORS PATIENTS

Page 48: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Conceptual Design

DOCTORS PATIENTS

Page 49: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Conceptual Design

DOCTORS

1. Doctor_ID2. Doctor_lname3. Doctor_fname4. Doctor_mi5. Doctor_specialty6. Doctor_address7. Doctor_phone8. Doctor_email

PATIENTS

1. Patient_ID2. Patient_lname3. Patient_fname4. Patient_mi5. Patient_address6. Patient_phone7. Patient_email

Page 50: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Logical Model Entities tables Relationship keys (primary and foreign) Many to many two one to many relationship

with an associate entity in the middle Normalization

Page 51: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Conceptual Model

DOCTORS

1. Doctor_ID2. Doctor_lname3. Doctor_fname4. Doctor_mi5. Doctor_specialty6. Doctor_address7. Doctor_phone8. Doctor_email

PATIENTS

1. Patient_ID2. Patient_lname3. Patient_fname4. Patient_mi5. Patient_address6. Patient_phone7. Patient_email

Page 52: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Logical Model

DOCTORS

1. Doctor_ID2. Doctor_lname3. Doctor_fname4. Doctor_mi5. Doctor_specialty6. Doctor_address7. Doctor_phone8. Doctor_email

PATIENTS

1. Patient_ID2. Patient_lname3. Patient_fname4. Patient_mi5. Patient_address6. Patient_phone7. Patient_email8. Doctor_ID

Page 53: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Conceptual Model

DOCTORS

1. Doctor_ID2. Doctor_lname3. Doctor_fname4. Doctor_mi5. Doctor_specialty6. Doctor_address7. Doctor_phone8. Doctor_email

PATIENTS

1. Patient_ID2. Patient_lname3. Patient_fname4. Patient_mi5. Patient_address6. Patient_phone7. Patient_email

Page 54: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Associate Entity/Bridge Table

DOCTORS

1. Doctor_ID2. Doctor_lname3. Doctor_fname4. Doctor_mi5. Doctor_specialty6. Doctor_address7. Doctor_phone8. Doctor_email

PATIENTS

1. Patient_ID2. Patient_lname3. Patient_fname4. Patient_mi5. Patient_address6. Patient_phone7. Patient_email

D_P

1. Patient_ID2. Doctor_ID

Page 55: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Physical Model

Doctor_ID

Doctor_lname

Doctor_fanme

Doctor_mi

Doctor_specialty

Doctor_address

Doctor_phone

Doctor_email

1 … … … … … … …

2 … … … … … … …

3 … … … … … … …

Patient_ID

Patient_lname

Patient_fname

Patient_MI

Patient_address

Patient_phone

Patient_email

001 … … … … … …

002 … … … … … …

003 … … … … … …

Patient_ID Doctor_ID

001 1

001 2

002 1

003 2

Relation Table

Tuple Row

Attribute Column

Page 56: Database Design HIMA 4160 Fall 2009. House Keeping  Assignment 4 due tonight  Assignment 5 due next Monday.

Summary on Data Modeling

Data model is the most critical aspect of system design and function

Data models should reflect real world objects and their relationships to ensure durability

A correct data model outlasts applications, including many not anticipated at system start-up