Download presentation
Presentation is loading. Please wait.
Published byElla Jordan Modified over 9 years ago
1
Introduction to Information and Computer Science Databases 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.
2
Databases and SQL Learning 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
3
Representing Data Identify entities (tables) Identify attributes (columns) Identify table relationships 6.8 Figure: Entity-Relationship Diagram (ER diagram) (PD-US, 2012) 3 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b
4
Relationships One-to-one One-to-many Many-to-many 4 Health 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)
5
Identify the Data A contact: –Person’s first name –Person’s last name –Company name –Company address –Company city –Company state 5 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b
6
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) 6 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b Contact Key PersonFirstName PersonLastName CoName CoAddress CoCity CoState
7
Contact Table Key PersonFirst Name PersonLast Name CoNameCoAddressCoCityCoState 1BillRobesonCommunity Hospital, Inc. 1312 MainPortlandOR 2AlbertBrookingsCommunity Hospital Inc. 1312 Main St.PortlandOR 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 7 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b
8
Database Normalization Prevent data inconsistency Prevent update errors Eliminate data redundancy 8 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b
9
Normalized Database Structure Two tables: Person and Company Each has a unique row identifier – a primary key Need to link the company to the contact 6.12 Figure: Normalized database structure (PD-US, 2012) 9 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b
10
New Tables Person Table ContactKeyFirstNameLastNameCompanyKey 1BillRobeson1 2AlbertBrookings1 6.13 Tables: New tables using same data from Table 6.5 (PD-US, 2012) 10 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b Company Table Company Key NameAddressCityState 1Community Hospital, Inc. 1312 MainPortlandOR
11
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 11 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b
12
Building a Database Database Management System Tools –Create tables –Create relationships –Control access –More… Structured Query Language (SQL) –Database management –Access to data 12 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b
13
Databases and SQL Summary – 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 13 Health IT Workforce Curriculum Version 3.0/Spring 2012 Introduction to Information and Computer Science Databases and SQL Lecture b
14
Databases and SQL References – 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). 14 Health 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)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.