SlideShare a Scribd company logo
1 of 22
Introduction to Computer Science
Databases and SQL
Lecture b
This material (Comp 4 Unit 5) 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 90WT0001.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
Databases and SQL
Learning Objectives - 1
• Define and describe the purpose of
databases (Lecture a)
• Describe a relational database (Lecture a)
• Describe data modeling and normalization
(Lecture b)
• Describe the structured query language
(SQL) (Lecture c)
2
Databases and SQL
Learning Objectives - 2
• 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 health care
database component (Lecture d)
3
Representing Data - 1
• Identify entities (tables)
• Identify attributes (columns)
• Identify table relationships
4
Representing Data - 2
• Identify entities (tables)
• Identify attributes (columns)
• Identify table relationships
Figure 1.1. Entity-Relationship Diagram (ER diagram)
5
Representing Data - 3
• Identify entities (tables)
• Identify attributes (columns)
• Identify table relationships
Figure 1.2. Entity-Relationship Diagram (ER diagram) with Patient table
6
Representing Data - 4
• Identify entities (tables)
• Identify attributes (columns)
• Identify table relationships
7
Figure 1.3. Entity-Relationship Diagram (ER diagram) with Patient and Insurance Company tables.
Relationships - 1
• One-to-one
• One-to-many
• Many-to-many
8
Relationships - 2
• One-to-one
• One-to-many
• Many-to-many
Figure 1.4. Entity-Relationship Diagram (ER diagram) with one-to-many relationship.
9
Relationships - 3
• One-to-one
• One-to-many
• Many-to-many
Figure 1.5. Entity-Relationship Diagram (ER diagram) with one-to-many relationship between
Insurance Company table and Patient table.
10
Relationships - 4
• One-to-one
• One-to-many
• Many-to-many
Figure 1.6. Entity-Relationship Diagram (ER diagram) with tables for Patient and Insurance
Company.
11
Relationships - 5
• One-to-one
• One-to-many
• Many-to-many
Figure 1.7. Entity-Relationship Diagram (ER diagram) with many-to-many relationship between
Patient and Insurance Company tables.
12
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) Figure 2. Contact attributes.
13
Contact Table
Figure 3. Contact table.
• Problems
– Company data is stored in multiple locations
– Company data may be inconsistent
– Significant work to update data when
company information changes
14
Database Normalization
• Prevent data inconsistency
• Prevent update errors
• Eliminate data redundancy
15
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
Figure 4. Normalized database structure.
16
New Tables
Figure 5. Top: New “Person” table using same data as previous “Contact” table. Bottom: New “Company”
table using same data as previous “Contact” table.
17
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
18
Building a Database
• Database Management System Tools
– Create tables
– Create relationships
– Control access
– More…
• Structured Query Language (SQL)
– Database management
– Access to data
19
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
20
Databases and SQL
References – Lecture b
References
Chen, P.P. (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), 120-125.
Figures
Figures 1.1-1.7: Entity-Relationship Diagrams. (2012). Public domain.
Figure 2. Contact attributes. (2012). Public domain.
Figure 3. Contact table. (2012). Public domain.
Figure 4. Normalized database structure. (2012). Public domain.
Figure 5. Top: New “Person” table using same data as previous “Contact” table. Bottom:
New “Company” table using same data as previous “Contact” table. (2012). Public
domain.
21
Introduction to Computer Science
Databases and SQL
Lecture b
This material 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 90WT0001.
22

More Related Content

What's hot

DISE - Database Concepts
DISE - Database ConceptsDISE - Database Concepts
DISE - Database Concepts
Rasan Samarasinghe
 
Influence of-structured--semi-structured--unstructured-data-on-various-data-m...
Influence of-structured--semi-structured--unstructured-data-on-various-data-m...Influence of-structured--semi-structured--unstructured-data-on-various-data-m...
Influence of-structured--semi-structured--unstructured-data-on-various-data-m...
shivz3
 

What's hot (20)

DISE - Database Concepts
DISE - Database ConceptsDISE - Database Concepts
DISE - Database Concepts
 
Different data models
Different data modelsDifferent data models
Different data models
 
Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data models
 
Design approach
Design approachDesign approach
Design approach
 
Data Modeling Basics
Data Modeling BasicsData Modeling Basics
Data Modeling Basics
 
Introduction to Data Modeling
Introduction to Data ModelingIntroduction to Data Modeling
Introduction to Data Modeling
 
All_Data_DBMS_MODELS 130725130028-phpapp01
All_Data_DBMS_MODELS 130725130028-phpapp01All_Data_DBMS_MODELS 130725130028-phpapp01
All_Data_DBMS_MODELS 130725130028-phpapp01
 
DATA BASE MODEL Rohini
DATA BASE MODEL RohiniDATA BASE MODEL Rohini
DATA BASE MODEL Rohini
 
Application of Unified Modelling Language
Application of Unified Modelling LanguageApplication of Unified Modelling Language
Application of Unified Modelling Language
 
DBMS and its Models
DBMS and its ModelsDBMS and its Models
DBMS and its Models
 
EDI Training Module 9: Explore EML with XML Editors
EDI Training Module 9:  Explore EML with XML EditorsEDI Training Module 9:  Explore EML with XML Editors
EDI Training Module 9: Explore EML with XML Editors
 
Introduction to databases
Introduction to databasesIntroduction to databases
Introduction to databases
 
EDI Training Module 5: Creating Clean Data foro Publishing
EDI Training Module 5:  Creating Clean Data foro PublishingEDI Training Module 5:  Creating Clean Data foro Publishing
EDI Training Module 5: Creating Clean Data foro Publishing
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Dbms Notes Lecture 4 : Data Models in DBMS
Dbms Notes Lecture 4 : Data Models in DBMSDbms Notes Lecture 4 : Data Models in DBMS
Dbms Notes Lecture 4 : Data Models in DBMS
 
Database Concept by Luke Lonergan
Database Concept by Luke LonerganDatabase Concept by Luke Lonergan
Database Concept by Luke Lonergan
 
Database and types of database
Database and types of databaseDatabase and types of database
Database and types of database
 
Influence of-structured--semi-structured--unstructured-data-on-various-data-m...
Influence of-structured--semi-structured--unstructured-data-on-various-data-m...Influence of-structured--semi-structured--unstructured-data-on-various-data-m...
Influence of-structured--semi-structured--unstructured-data-on-various-data-m...
 
Database Review and Challenges (2016)
Database Review and Challenges (2016)Database Review and Challenges (2016)
Database Review and Challenges (2016)
 
Data models
Data modelsData models
Data models
 

Similar to Databases and SQL - Lecture B

Lecture-8-The-GIS-Database-Part-1.ppt
Lecture-8-The-GIS-Database-Part-1.pptLecture-8-The-GIS-Database-Part-1.ppt
Lecture-8-The-GIS-Database-Part-1.ppt
Prabin Pandit
 

Similar to Databases and SQL - Lecture B (20)

Advanced Database Systems - Presentation 1 with quiz.pptx
Advanced Database Systems - Presentation 1 with quiz.pptxAdvanced Database Systems - Presentation 1 with quiz.pptx
Advanced Database Systems - Presentation 1 with quiz.pptx
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
 
Databases and its representation
Databases and its representationDatabases and its representation
Databases and its representation
 
Dbms slide share.pptx
Dbms slide share.pptxDbms slide share.pptx
Dbms slide share.pptx
 
T-SQL
T-SQLT-SQL
T-SQL
 
Lecture-8-The-GIS-Database-Part-1.ppt
Lecture-8-The-GIS-Database-Part-1.pptLecture-8-The-GIS-Database-Part-1.ppt
Lecture-8-The-GIS-Database-Part-1.ppt
 
7 - Enterprise IT in Action
7 - Enterprise IT in Action7 - Enterprise IT in Action
7 - Enterprise IT in Action
 
DBMS & Data Models - In Introduction
DBMS & Data Models - In IntroductionDBMS & Data Models - In Introduction
DBMS & Data Models - In Introduction
 
Database systems introduction
Database systems introductionDatabase systems introduction
Database systems introduction
 
Data Mining And Data Warehousing Laboratory File Manual
Data Mining And Data Warehousing Laboratory File ManualData Mining And Data Warehousing Laboratory File Manual
Data Mining And Data Warehousing Laboratory File Manual
 
Relational Database explanation with detail.pdf
Relational Database explanation with detail.pdfRelational Database explanation with detail.pdf
Relational Database explanation with detail.pdf
 
Cse ii ii sem
Cse ii ii semCse ii ii sem
Cse ii ii sem
 
lecture5 (1) (2).pptx
lecture5 (1) (2).pptxlecture5 (1) (2).pptx
lecture5 (1) (2).pptx
 
PP DBMS - 1 (2).pptx
PP DBMS - 1 (2).pptxPP DBMS - 1 (2).pptx
PP DBMS - 1 (2).pptx
 
PP DBMS - 1 (1).pptx
PP DBMS - 1 (1).pptxPP DBMS - 1 (1).pptx
PP DBMS - 1 (1).pptx
 
PP DBMS - 1 (1).pptx
PP DBMS - 1 (1).pptxPP DBMS - 1 (1).pptx
PP DBMS - 1 (1).pptx
 
Access
AccessAccess
Access
 
ADV Powepoint 1 Lec.pptx
ADV Powepoint 1 Lec.pptxADV Powepoint 1 Lec.pptx
ADV Powepoint 1 Lec.pptx
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 

More from CMDLearning

More from CMDLearning (20)

What is Health Informatics - Lecture B
What is Health Informatics - Lecture BWhat is Health Informatics - Lecture B
What is Health Informatics - Lecture B
 
Evolution of and Trends in Health Care - Lecture D
Evolution of and Trends in Health Care - Lecture DEvolution of and Trends in Health Care - Lecture D
Evolution of and Trends in Health Care - Lecture D
 
Evolution of and Trends in Health Care - Lecture C
Evolution of and Trends in Health Care - Lecture CEvolution of and Trends in Health Care - Lecture C
Evolution of and Trends in Health Care - Lecture C
 
Evolution of and Trends in Health Care - Lecture B
Evolution of and Trends in Health Care - Lecture BEvolution of and Trends in Health Care - Lecture B
Evolution of and Trends in Health Care - Lecture B
 
Evolution of and Trends in Health Care - Lecture A
Evolution of and Trends in Health Care - Lecture AEvolution of and Trends in Health Care - Lecture A
Evolution of and Trends in Health Care - Lecture A
 
Public Healthcare (Part 2) Lecture C
Public Healthcare (Part 2) Lecture CPublic Healthcare (Part 2) Lecture C
Public Healthcare (Part 2) Lecture C
 
Public Healthcare (Part 2) Lecture B
Public Healthcare (Part 2) Lecture BPublic Healthcare (Part 2) Lecture B
Public Healthcare (Part 2) Lecture B
 
Public Healthcare (Part 2) Lecture A
Public Healthcare (Part 2) Lecture APublic Healthcare (Part 2) Lecture A
Public Healthcare (Part 2) Lecture A
 
Public Health (Part 1) Lecture C
Public Health (Part 1) Lecture CPublic Health (Part 1) Lecture C
Public Health (Part 1) Lecture C
 
Public Health (Part 1) Lecture B
Public Health (Part 1) Lecture BPublic Health (Part 1) Lecture B
Public Health (Part 1) Lecture B
 
Public Health (Part 1) Lecture A
Public Health (Part 1) Lecture APublic Health (Part 1) Lecture A
Public Health (Part 1) Lecture A
 
Regulating Healthcare - Lecture E
Regulating Healthcare - Lecture ERegulating Healthcare - Lecture E
Regulating Healthcare - Lecture E
 
Regulating Healthcare - Lecture D
Regulating Healthcare - Lecture DRegulating Healthcare - Lecture D
Regulating Healthcare - Lecture D
 
Regulating Healthcare - Lecture C
Regulating Healthcare - Lecture CRegulating Healthcare - Lecture C
Regulating Healthcare - Lecture C
 
Regulating Healthcare - Lecture A
Regulating Healthcare - Lecture ARegulating Healthcare - Lecture A
Regulating Healthcare - Lecture A
 
Regulating Healthcare - Lecture B
Regulating Healthcare - Lecture BRegulating Healthcare - Lecture B
Regulating Healthcare - Lecture B
 
Financing Healthcare (Part 2) Lecture C
Financing Healthcare (Part 2) Lecture CFinancing Healthcare (Part 2) Lecture C
Financing Healthcare (Part 2) Lecture C
 
Financing Healthcare (Part 2) Lecture B
Financing Healthcare (Part 2) Lecture BFinancing Healthcare (Part 2) Lecture B
Financing Healthcare (Part 2) Lecture B
 
Financing Healthcare (Part 2) Lecture A
Financing Healthcare (Part 2) Lecture AFinancing Healthcare (Part 2) Lecture A
Financing Healthcare (Part 2) Lecture A
 
Financing Healthcare (Part 2) Lecture D
Financing Healthcare (Part 2) Lecture DFinancing Healthcare (Part 2) Lecture D
Financing Healthcare (Part 2) Lecture D
 

Recently uploaded

Tirupati Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Tirupati Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetTirupati Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Tirupati Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Call Girls Service
 
VIP Call Girl Sector 32 Noida Just Book Me 9711199171
VIP Call Girl Sector 32 Noida Just Book Me 9711199171VIP Call Girl Sector 32 Noida Just Book Me 9711199171
VIP Call Girl Sector 32 Noida Just Book Me 9711199171
Call Girls Service Gurgaon
 
Bareilly Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Bareilly Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetBareilly Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Bareilly Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Call Girls Service
 
bhubaneswar Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
bhubaneswar Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meetbhubaneswar Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
bhubaneswar Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Call Girls Service
 
Ernakulam Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Ernakulam Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetErnakulam Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Ernakulam Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Call Girls Chandigarh
 
Call Girls Chandigarh 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
Call Girls Chandigarh 👙 7001035870 👙 Genuine WhatsApp Number for Real MeetCall Girls Chandigarh 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
Call Girls Chandigarh 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
priyashah722354
 
VIP Call Girls Noida Sia 9711199171 High Class Call Girl Near Me
VIP Call Girls Noida Sia 9711199171 High Class Call Girl Near MeVIP Call Girls Noida Sia 9711199171 High Class Call Girl Near Me
VIP Call Girls Noida Sia 9711199171 High Class Call Girl Near Me
mriyagarg453
 
Hubli Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Hubli Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetHubli Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Hubli Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Call Girls Service
 
Call Girls Service Anantapur 📲 6297143586 Book Now VIP Call Girls in Anantapur
Call Girls Service Anantapur 📲 6297143586 Book Now VIP Call Girls in AnantapurCall Girls Service Anantapur 📲 6297143586 Book Now VIP Call Girls in Anantapur
Call Girls Service Anantapur 📲 6297143586 Book Now VIP Call Girls in Anantapur
gragmanisha42
 
9316020077📞Goa Call Girls Numbers, Call Girls Whatsapp Numbers Goa
9316020077📞Goa  Call Girls  Numbers, Call Girls  Whatsapp Numbers Goa9316020077📞Goa  Call Girls  Numbers, Call Girls  Whatsapp Numbers Goa
9316020077📞Goa Call Girls Numbers, Call Girls Whatsapp Numbers Goa
russian goa call girl and escorts service
 
raisen Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
raisen Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meetraisen Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
raisen Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Call Girls Service
 
Ozhukarai Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Ozhukarai Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetOzhukarai Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Ozhukarai Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Call Girls Service
 

Recently uploaded (20)

Call Girl Raipur 📲 9999965857 ヅ10k NiGhT Call Girls In Raipur
Call Girl Raipur 📲 9999965857 ヅ10k NiGhT Call Girls In RaipurCall Girl Raipur 📲 9999965857 ヅ10k NiGhT Call Girls In Raipur
Call Girl Raipur 📲 9999965857 ヅ10k NiGhT Call Girls In Raipur
 
❤️♀️@ Jaipur Call Girls ❤️♀️@ Meghna Jaipur Call Girls Number CRTHNR Call G...
❤️♀️@ Jaipur Call Girls ❤️♀️@ Meghna Jaipur Call Girls Number CRTHNR   Call G...❤️♀️@ Jaipur Call Girls ❤️♀️@ Meghna Jaipur Call Girls Number CRTHNR   Call G...
❤️♀️@ Jaipur Call Girls ❤️♀️@ Meghna Jaipur Call Girls Number CRTHNR Call G...
 
Tirupati Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Tirupati Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetTirupati Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Tirupati Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
 
VIP Call Girl Sector 32 Noida Just Book Me 9711199171
VIP Call Girl Sector 32 Noida Just Book Me 9711199171VIP Call Girl Sector 32 Noida Just Book Me 9711199171
VIP Call Girl Sector 32 Noida Just Book Me 9711199171
 
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★
Enjoyment ★ 8854095900 Indian Call Girls In Dehradun 🍆🍌 By Dehradun Call Girl ★
 
Krishnagiri call girls Tamil aunty 7877702510
Krishnagiri call girls Tamil aunty 7877702510Krishnagiri call girls Tamil aunty 7877702510
Krishnagiri call girls Tamil aunty 7877702510
 
Call Girl Raipur 📲 9999965857 whatsapp live cam sex service available
Call Girl Raipur 📲 9999965857 whatsapp live cam sex service availableCall Girl Raipur 📲 9999965857 whatsapp live cam sex service available
Call Girl Raipur 📲 9999965857 whatsapp live cam sex service available
 
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF ...
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF  ...❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF  ...
❤️♀️@ Jaipur Call Girls ❤️♀️@ Jaispreet Call Girl Services in Jaipur QRYPCF ...
 
Bareilly Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Bareilly Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetBareilly Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Bareilly Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
 
bhubaneswar Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
bhubaneswar Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meetbhubaneswar Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
bhubaneswar Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
 
Ernakulam Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Ernakulam Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetErnakulam Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Ernakulam Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
 
Call Girls Chandigarh 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
Call Girls Chandigarh 👙 7001035870 👙 Genuine WhatsApp Number for Real MeetCall Girls Chandigarh 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
Call Girls Chandigarh 👙 7001035870 👙 Genuine WhatsApp Number for Real Meet
 
VIP Call Girls Noida Sia 9711199171 High Class Call Girl Near Me
VIP Call Girls Noida Sia 9711199171 High Class Call Girl Near MeVIP Call Girls Noida Sia 9711199171 High Class Call Girl Near Me
VIP Call Girls Noida Sia 9711199171 High Class Call Girl Near Me
 
Hubli Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Hubli Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetHubli Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Hubli Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
 
Call Girls Service Anantapur 📲 6297143586 Book Now VIP Call Girls in Anantapur
Call Girls Service Anantapur 📲 6297143586 Book Now VIP Call Girls in AnantapurCall Girls Service Anantapur 📲 6297143586 Book Now VIP Call Girls in Anantapur
Call Girls Service Anantapur 📲 6297143586 Book Now VIP Call Girls in Anantapur
 
9316020077📞Goa Call Girls Numbers, Call Girls Whatsapp Numbers Goa
9316020077📞Goa  Call Girls  Numbers, Call Girls  Whatsapp Numbers Goa9316020077📞Goa  Call Girls  Numbers, Call Girls  Whatsapp Numbers Goa
9316020077📞Goa Call Girls Numbers, Call Girls Whatsapp Numbers Goa
 
raisen Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
raisen Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meetraisen Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
raisen Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
 
(Deeksha) 💓 9920725232 💓High Profile Call Girls Navi Mumbai You Can Get The S...
(Deeksha) 💓 9920725232 💓High Profile Call Girls Navi Mumbai You Can Get The S...(Deeksha) 💓 9920725232 💓High Profile Call Girls Navi Mumbai You Can Get The S...
(Deeksha) 💓 9920725232 💓High Profile Call Girls Navi Mumbai You Can Get The S...
 
Ozhukarai Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Ozhukarai Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real MeetOzhukarai Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
Ozhukarai Call Girls 👙 6297143586 👙 Genuine WhatsApp Number for Real Meet
 
Call Girls Patiala Just Call 8250077686 Top Class Call Girl Service Available
Call Girls Patiala Just Call 8250077686 Top Class Call Girl Service AvailableCall Girls Patiala Just Call 8250077686 Top Class Call Girl Service Available
Call Girls Patiala Just Call 8250077686 Top Class Call Girl Service Available
 

Databases and SQL - Lecture B

  • 1. Introduction to Computer Science Databases and SQL Lecture b This material (Comp 4 Unit 5) 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 90WT0001. This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
  • 2. Databases and SQL Learning Objectives - 1 • Define and describe the purpose of databases (Lecture a) • Describe a relational database (Lecture a) • Describe data modeling and normalization (Lecture b) • Describe the structured query language (SQL) (Lecture c) 2
  • 3. Databases and SQL Learning Objectives - 2 • 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 health care database component (Lecture d) 3
  • 4. Representing Data - 1 • Identify entities (tables) • Identify attributes (columns) • Identify table relationships 4
  • 5. Representing Data - 2 • Identify entities (tables) • Identify attributes (columns) • Identify table relationships Figure 1.1. Entity-Relationship Diagram (ER diagram) 5
  • 6. Representing Data - 3 • Identify entities (tables) • Identify attributes (columns) • Identify table relationships Figure 1.2. Entity-Relationship Diagram (ER diagram) with Patient table 6
  • 7. Representing Data - 4 • Identify entities (tables) • Identify attributes (columns) • Identify table relationships 7 Figure 1.3. Entity-Relationship Diagram (ER diagram) with Patient and Insurance Company tables.
  • 8. Relationships - 1 • One-to-one • One-to-many • Many-to-many 8
  • 9. Relationships - 2 • One-to-one • One-to-many • Many-to-many Figure 1.4. Entity-Relationship Diagram (ER diagram) with one-to-many relationship. 9
  • 10. Relationships - 3 • One-to-one • One-to-many • Many-to-many Figure 1.5. Entity-Relationship Diagram (ER diagram) with one-to-many relationship between Insurance Company table and Patient table. 10
  • 11. Relationships - 4 • One-to-one • One-to-many • Many-to-many Figure 1.6. Entity-Relationship Diagram (ER diagram) with tables for Patient and Insurance Company. 11
  • 12. Relationships - 5 • One-to-one • One-to-many • Many-to-many Figure 1.7. Entity-Relationship Diagram (ER diagram) with many-to-many relationship between Patient and Insurance Company tables. 12
  • 13. 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) Figure 2. Contact attributes. 13
  • 14. Contact Table Figure 3. Contact table. • Problems – Company data is stored in multiple locations – Company data may be inconsistent – Significant work to update data when company information changes 14
  • 15. Database Normalization • Prevent data inconsistency • Prevent update errors • Eliminate data redundancy 15
  • 16. 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 Figure 4. Normalized database structure. 16
  • 17. New Tables Figure 5. Top: New “Person” table using same data as previous “Contact” table. Bottom: New “Company” table using same data as previous “Contact” table. 17
  • 18. 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 18
  • 19. Building a Database • Database Management System Tools – Create tables – Create relationships – Control access – More… • Structured Query Language (SQL) – Database management – Access to data 19
  • 20. 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 20
  • 21. Databases and SQL References – Lecture b References Chen, P.P. (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), 120-125. Figures Figures 1.1-1.7: Entity-Relationship Diagrams. (2012). Public domain. Figure 2. Contact attributes. (2012). Public domain. Figure 3. Contact table. (2012). Public domain. Figure 4. Normalized database structure. (2012). Public domain. Figure 5. Top: New “Person” table using same data as previous “Contact” table. Bottom: New “Company” table using same data as previous “Contact” table. (2012). Public domain. 21
  • 22. Introduction to Computer Science Databases and SQL Lecture b This material 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 90WT0001. 22

Editor's Notes

  1. Welcome to Introduction to Computer Science: Databases and Structured Query Language, or SQL. This is lecture b. The component, Introduction to Computer Science, is a basic overview of computer architecture; data organization, representation and structure; structure of programming languages; networking and data communication. It also includes the basic terminology of computing.
  2. The learning objectives for Databases and SQL are to: Define and describe the purpose of databases Describe a relational database Describe data modeling and normalization Describe the structured query language, or SQL
  3. Define the basic data operations for relational databases and how to implement them in SQL Design a simple relational database and create corresponding SQL commands And, examine the structure of a health care database component
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. References slide. No audio.
  22. No audio.