Introduction to Information and Computer Science Databases and SQL Lecture c This material (Comp4_Unit6c) was developed by Oregon Health and Science University, funded by the Department of Health and Human Services, Office of the National Coordinator for Health Information Technology under Award Number IU24OC000015.
25
Embed
Introduction to Information and Computer Science Databases and SQL Lecture c This material (Comp4_Unit6c) was developed by Oregon Health and Science University,
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
Introduction to Information and Computer Science
Databases and SQL
Lecture c
This material (Comp4_Unit6c) was developed by Oregon Health and 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
• 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)
2Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture c
SQL
• Used to manage and access database information
• ANSI, ISO and IEC standard– DBMS have custom extensions!
• Extensive language– We’ll look at a few basic commands
3Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture c
Example
• Make a space for the tables by creating the database– create database <name>
sql> create database contacts• To remove:
– drop database <name>
4Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture c
Create the Tables
• create table <name> (<column information>);• Column information consists of column names
and data types• Tables also have extra information• To remove:
– drop table <name>
5Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture c
SQL Basic Data Types
Data Type Description
integer or int Whole numbers
float Floating point number
date Date
time Time
char (length) Fixed number of characters
varchar (length) Variable number of characters
6.14 Table: SQL Basic Data Types (PD-US, 2011).
6Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL
Lecture c
Create Company Table
sql> create table company (id integer auto_increment,
-> name varchar(50),
-> address varchar(50),
-> city varchar(50),
-> state char(2),
-> primary key(id));
7Health IT Workforce Curriculum Version 3.0/Spring 2012
Introduction to Information and Computer Science Databases and SQL