Date post: | 06-May-2017 |
Category: |
Documents |
Upload: | health-it-workforce-curriculum-2012 |
View: | 237 times |
Download: | 0 times |
Introduction to Information and Computer ScienceDatabases and SQL
Lecture b
This material (Comp4_Unit6b) was developed by Oregon Health & Science University, funded by the Department of Health and Human Services, Office of the National Coordinator for Health Information Technology under Award Number
IU24OC000015.
Databases and SQLLearning Objectives
2
• Define and describe the purpose of databases (Lecture a)• Define a relational database (Lecture a)• Describe data modeling and normalization (Lecture b)• Describe the structured query language (SQL) (Lecture c)• Define the basic data operations for relational databases and how to
implement them in SQL (Lecture c)• Design a simple relational database and create corresponding SQL
commands (Lecture c)• Examine the structure of a healthcare database component (Lecture
d)
Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Representing Data• Identify entities (tables)• Identify attributes (columns)• Identify table relationships
6.8 Figure: Entity-Relationship Diagram (ER diagram) (PD-US, 2012)
3Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Relationships• One-to-one• One-to-many• Many-to-many
4Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
6.9 Figure: One-to-many relationship (PD-US, 2012)
Identify the Data
• A contact:– Person’s first name– Person’s last name– Company name– Company address– Company city– Company state
5Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Simple Database Structure• One entity/table• Create a unique row identifier• Attributes:
– Key (integer)– Person’s first name (varchar)– Person’s last name (varchar)– Company name (varchar)– Company address (varchar)– Company city (varchar)– Company state (char)
6.10 Table: Contact attributes (PD-US, 2012)
6Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
ContactKeyPersonFirstNamePersonLastNameCoNameCoAddressCoCityCoState
Contact TableKey PersonFirst
NamePersonLastName
CoName CoAddress CoCity CoState
1 Bill Robeson Community Hospital, Inc.
1312 Main Portland OR
2 Albert Brookings Community Hospital Inc.
1312 Main St. Portland OR
6.11 Table: Contact table (PD-US, 2012)
Problems:– Company data is stored in multiple locations– Company data may be inconsistent– Significant work to update data when company
information changes
7Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Database Normalization
• Prevent data inconsistency• Prevent update errors• Eliminate data redundancy
8Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Normalized Database StructureTwo tables: Person and CompanyEach has a unique row identifier – a primary keyNeed to link the company to the contact
6.12 Figure: Normalized database structure (PD-US, 2012)
9Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
New Tables
Person Table
ContactKey FirstName LastName CompanyKey
1 Bill Robeson 1
2 Albert Brookings 1
6.13 Tables: New tables using same data from Table 6.5 (PD-US, 2012)
10Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Company Table
CompanyKey
Name Address City State
1 Community Hospital, Inc.
1312 Main Portland OR
How Do We Do This?• Database Management System
– Create– Maintain– Use
• Many available (NOT an exhaustive list)– Oracle– Microsoft SQL Server– IBM DB2– MySQL– PostgreSQL
11Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Building a Database
• Database Management System Tools– Create tables– Create relationships– Control access– More…
• Structured Query Language (SQL)– Database management– Access to data
12Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Databases and SQLSummary – Lecture b
• Databases can be modeled using entity relationship diagrams
• Relationships can have 3 different types of cardinality
• Normalization avoids duplicate data• Relationships are created using foreign keys
13Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Databases and SQLReferences – Lecture b
References• Chen, P. P.-S. (1976). The Entity-Relationship Model - Toward a Unified View of Data. ACM Transactions on
Database Systems, 1(1).• International Organization for Standardization. (2008). Information technology -- Database languages -- SQL (No.
ISO/IEC 9075-(1-4,9-11,13,14)).• Kent, W. (1983). A simple guide to five normal forms in relational database theory. Communications of the ACM,
26(2).
14Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture b
Charts, Tables, Figures• 6.8 Figure: Entity-Relationship Diagram (ER diagram) (PD-US, 2012)• 6.9 Figure: One-to-many relationship (PD-US, 2012)• 6.10 Table: Contact attributes (PD-US, 2012)• 6.11 Table: Contact table (PD-US, 2012)• 6.12 Figure: Normalized database structure (PD-US, 2012)• 6.13 Tables: New tables using same data from Table 6.5 (PD-US, 2012)