SlideShare a Scribd company logo
SQL200   Based on  SQL Clearly Explained  by Jan Harrington SQL Programming Module  1 – Relational Database Background, Basic Single Table Retrieval Operations
SQL200 P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com [email_address]
SQL Programming Course focus is SQL language Widely used for: Database administration Enterprise application development Data driven web sites A foundation skill for eBusiness and almost all major business applications that use relational databases
SQL Programming A basic knowledge of query systems, perhaps via MS Access,  or some programming knowledge, is desirable We will use GUI tools or Access “SQL View” almost exclusively
Relational Database Evolution Based on Codd’s paper Early commercial efforts focused on Unix First mainframe implementation by IBM  - precursor to today’s DB2 First PC implementation in early 80’s by Oracle
Relational Database Basics Storage Databases Tables Rows Columns Indexes Views Cursors Application interfaces
Relational Database Table
Constraints Database Domain Uniqueness Relationship Cardinality 1 to 1 1 to N Other Business Rule Triggers Stored Procedures
Relational Database with constraints
Database Management Systems Positioning Chart VLDB Enterprise Workgroup Single user Spreadsheet # Users Cost
System Architecture Access MDB File Server  Architecture Access
System Architecture Oracle DB Visual Basic App Client/Server  Architecture Access  SQL 
System Architecture Oracle DB Browser Web  Architecture Web Server  SQL 
Approaching SQL Relatively simple Two main environments Interactive (This course) Embedded Static (Compiled) Dynamic
SQL Standardization ANSI standardization First standard in 1986 SQL 89 SQL 92 SQL 99 Various vendor extensions Microsoft/Sybase: T-SQL Oracle: PL/SQL
SQL Conformance Entry Intermediate Advanced Most are at least entry level
SQL Statements Data Manipulation Language (DML) Data Control Language (DCL) Data Definition Language (DDL) Note: SQL 99 changes these to seven types
SQL DDL Data definition language (DDL) Create, alter, drop, etc. Frequently implemented via various CASE tools: Visio, Embarcadero, ERWin, etc. But very useful for database administration
SQL DCL Data Control Language (DDL) Grant Revoke Constraints
SQL DML Data Manipulation Language (DML) Select Insert Update Delete
SQL Statement Processing Parse Validate Optimize Access Plan Execute
Bookstore Sample Database Before we continue (note: instructor may have already done this)… Load the sample database if you haven’t already Use Access import table feature, or Run SQL script, or Use Access upsizing wizard
Text Conventions In Access character strings are normally surrounded by double quotes “ Jones” In an enterprise database such as Oracle or SQL Sever, then single quotes ‘ Jones’ Be   sensitive to the environment of your class in copying scripts from the PowerPoint slides!
Date Conventions In Access date are normally surrounded by pound signs #12/23/2004# In an enterprise database such as Oracle or SQL Sever, then single quotes ‘ 2004-12-23’ MySQL ’ 12-23-2004’ SQL Server ’ 23-DEC-04’ Oracle Be   sensitive to the environment of your class in copying scripts from the PowerPoint slides!
SELECT Basic Syntax ( Projection ): Select <column-list> or <*> From <table-list>
SELECT Basic Example ( Projection ): select   customer_last_name,  customer_street from  customers
MS Access SQL Query
 
SQL Server Query
SELECT with Where Clause Example ( Restriction  plus   Projection ): Select <column-list> From <table-list> Where <selection-criteria>;
SELECT with Where Basic Example ( Restriction plus Projection ): select   customer_last_name,  customer_street from  customers where  customer_last_name = “Jones”
Select with Where
On Your Own Find books written by Mark Twain Show title, publisher, year
Complex Predicates Follow normal boolean logic Select   customer_last_name,  customer_street From  customers Where  (customer_last_name = ‘Jones’ or customer_last_name = ‘Smith’)and customer_state=‘NY’
Select with Complex Where
Complex Where Result
Special Operators Can be used in where clause LIKE IN BETWEEN IS NULL
Like (“Wild Card Matches”) ANSI Where customer_last_name like “Jo%” Like “Jo_” Access Where customer_last_name like “Jo*” Like “Jo?”
IN Select  * From  customers Where  customer_last_name in (“Rizzo”, “Jones”, “Garcia”) The list in parentheses can be replaced by a subquery. We will study this later.
SQL Where Clause with IN
IS NULL Select  * From  customers Where  customer_street IS NULL  SQL uses three valued logic. Must use IS NULL to test for unknowns. A null is NOT the same as blank or empty.
On Your Own Find all customers with an address not equal to 4592 Maple Lane Was Peter Johnson selected? Why or why not?
BETWEEN Select * From orders Where order_date BETWEEN #1/1/99# and #12/31/99# Note: date formats vary from product to product. Above is Access syntax, SQL Server uses single quotes. Ex: ‘1/1/99’
Where with Between
Removing Duplicates Select DISTINCT  customer_city From  customers List once each city in which there are customers Removes duplicate rows from result set
Removing Duplicates
Sorting – ORDER BY DESC will sort in descending order Basic syntax : Select <column list> From <table list> Where <selection criteria> Order by <column list> [DESC]
Sorting – ORDER BY Select  * From  customers Order by  customer_state, customer_city Example: List all records sorted by state, city
Sorting Results with Order By
Selecting Top Records Select Top 5 (or top 25 percent)  Customer_last_name  , contact_zip From  customers Order by customer_zip  desc ; List largest 5 zips or top 25 % of them…
SQL Exercises List all books whose publisher name begins with “H” or “T”; sort by title [hint: use LIKE] List all customers whose last name ends with “S”; sort by state, city, last name Find the order numbers of orders with order dates in 1999; sort by order #. [Hint: use BETWEEN] Find the order numbers and order dates of all orders with a “2” in column 2 of the credit card #; sort by order date descending [end module]

More Related Content

PPT
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
PPT
Sql 2006
PPTX
Introduction to SQL
PDF
Database Management Essentials: Module 4 Basic Query Formulation with SQL
PPT
Sql server T-sql basics ppt-3
PPTX
Intro to T-SQL – 2nd session
PDF
PPTX
Intro to T-SQL - 1st session
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
Sql 2006
Introduction to SQL
Database Management Essentials: Module 4 Basic Query Formulation with SQL
Sql server T-sql basics ppt-3
Intro to T-SQL – 2nd session
Intro to T-SQL - 1st session

What's hot (19)

PDF
Sql tutorial
PPT
SQL212.1 Introduction to SQL using Oracle Module 1
PPTX
Introduction to SQL (for Chicago Booth MBA technology club)
PPT
Introduction to sql
ODP
BIS05 Introduction to SQL
PPTX
Intro to t sql – 3rd session
PDF
Sql tutorial-Structured query language
PPTX
Xml part2
PPT
Chapter 07 ddl_sql
PDF
SQL Overview
PPT
Sql intro & ddl 1
PPTX
Introduction to SQL
PPTX
Xml and databases
PPTX
Xml part1
PPT
Internet Environment
PPTX
Xml part3
PDF
PDF
Introduction to the Structured Query Language SQL
PDF
Chapter 4 Structured Query Language
Sql tutorial
SQL212.1 Introduction to SQL using Oracle Module 1
Introduction to SQL (for Chicago Booth MBA technology club)
Introduction to sql
BIS05 Introduction to SQL
Intro to t sql – 3rd session
Sql tutorial-Structured query language
Xml part2
Chapter 07 ddl_sql
SQL Overview
Sql intro & ddl 1
Introduction to SQL
Xml and databases
Xml part1
Internet Environment
Xml part3
Introduction to the Structured Query Language SQL
Chapter 4 Structured Query Language
Ad

Viewers also liked (20)

PPT
Preparing Students
PPTX
PPT
RENÉ DESCARTES : PERFIL
ODP
ELS SILENCIS D'ORIENT
PPTX
Digital Public Records
PDF
IntelliStick
PDF
Il Mostro Di Cogne
 
PPTX
Vhag profile 2013
PDF
青年創業及圓夢網 創業稅務大小事【創業懶人包 】
PPT
Link Journalism: Curation to increase trust, relevance, brevity and pageviews
PDF
Muziekdigitaal Taggerfm Pitch 091027
PDF
AIN100
PPT
AVB201.1 Microsoft Access VBA Module 1
PDF
SQL212 Oracle SQL Manual
PDF
My Web Portfolio
PPT
SQL302 Intermediate SQL Workshop 2
PDF
Tagger.fm Muziek Digitaal 091028
PDF
SQL201W MySQL SQL Manual
PPT
Alles Van Tmm
PDF
Terranova Brochure
Preparing Students
RENÉ DESCARTES : PERFIL
ELS SILENCIS D'ORIENT
Digital Public Records
IntelliStick
Il Mostro Di Cogne
 
Vhag profile 2013
青年創業及圓夢網 創業稅務大小事【創業懶人包 】
Link Journalism: Curation to increase trust, relevance, brevity and pageviews
Muziekdigitaal Taggerfm Pitch 091027
AIN100
AVB201.1 Microsoft Access VBA Module 1
SQL212 Oracle SQL Manual
My Web Portfolio
SQL302 Intermediate SQL Workshop 2
Tagger.fm Muziek Digitaal 091028
SQL201W MySQL SQL Manual
Alles Van Tmm
Terranova Brochure
Ad

Similar to SQL200.1 Module 1 (20)

PPTX
introduction to SQL query language beginner.ppt
PDF
MIS5101 WK10 Outcome Measures
PDF
SQL-for-Data-Analytics-Top-10-Queries-Every-Analyst-Should-Know
PDF
SQL & Adv SQL - Basics and Advanced for Beginners
PPTX
Structure Query Language Advance Training
PPTX
SQL-Demystified-A-Beginners-Guide-to-Database-Mastery.pptx
DOCX
Learning sql from w3schools
PPT
Module02
PDF
Sq lite module6
PPTX
Chapter 2: Ms SQL Server
PPTX
Introduction to Database SQL & PL/SQL
DOCX
PDF
SQL - RDBMS Concepts
PPT
MYSQL.ppt
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
PPT
Introduction to Oracle
PPT
Introduction to Oracle
PPTX
Sql for biggner
PPTX
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
introduction to SQL query language beginner.ppt
MIS5101 WK10 Outcome Measures
SQL-for-Data-Analytics-Top-10-Queries-Every-Analyst-Should-Know
SQL & Adv SQL - Basics and Advanced for Beginners
Structure Query Language Advance Training
SQL-Demystified-A-Beginners-Guide-to-Database-Mastery.pptx
Learning sql from w3schools
Module02
Sq lite module6
Chapter 2: Ms SQL Server
Introduction to Database SQL & PL/SQL
SQL - RDBMS Concepts
MYSQL.ppt
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
Introduction to Oracle
Introduction to Oracle
Sql for biggner
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx

More from Dan D'Urso (20)

PPT
SQL201S Accelerated Introduction to MySQL Queries
PPT
LCD201d Database Diagramming with Lucidchart
PPTX
Database Normalization
PPT
VIS201d Visio Database Diagramming
PPT
PRJ101a Project 2013 Accelerated
PPT
PRJ101xl Project Libre Basic Training
PPT
Introduction to coding using Python
PPTX
Stem conference
PDF
SQL200A Microsoft Access SQL Design
PPTX
Microsoft access self joins
PDF
SQL302 Intermediate SQL
PDF
AIN106 Access Reporting and Analysis
PPT
SQL302 Intermediate SQL Workshop 3
PDF
Course Catalog
PPT
SQL302 Intermediate SQL Workshop 1
PPT
SQL206 SQL Median
PPT
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
PPT
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
PDF
SQL202 SQL Server SQL Manual
PDF
AIN102 Microsoft Access Queries
SQL201S Accelerated Introduction to MySQL Queries
LCD201d Database Diagramming with Lucidchart
Database Normalization
VIS201d Visio Database Diagramming
PRJ101a Project 2013 Accelerated
PRJ101xl Project Libre Basic Training
Introduction to coding using Python
Stem conference
SQL200A Microsoft Access SQL Design
Microsoft access self joins
SQL302 Intermediate SQL
AIN106 Access Reporting and Analysis
SQL302 Intermediate SQL Workshop 3
Course Catalog
SQL302 Intermediate SQL Workshop 1
SQL206 SQL Median
SQL202.3 Accelerated Introduction to SQL Using SQL Server Module 3
SQL202.2 Accelerated Introduction to SQL Using SQL Server Module 2
SQL202 SQL Server SQL Manual
AIN102 Microsoft Access Queries

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Understanding_Digital_Forensics_Presentation.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
MYSQL Presentation for SQL database connectivity
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
Mobile App Security Testing_ A Comprehensive Guide.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf

SQL200.1 Module 1

  • 1. SQL200 Based on SQL Clearly Explained by Jan Harrington SQL Programming Module 1 – Relational Database Background, Basic Single Table Retrieval Operations
  • 2. SQL200 P.O. Box 6142 Laguna Niguel, CA 92607 949-489-1472 http://www.d2associates.com [email_address]
  • 3. SQL Programming Course focus is SQL language Widely used for: Database administration Enterprise application development Data driven web sites A foundation skill for eBusiness and almost all major business applications that use relational databases
  • 4. SQL Programming A basic knowledge of query systems, perhaps via MS Access, or some programming knowledge, is desirable We will use GUI tools or Access “SQL View” almost exclusively
  • 5. Relational Database Evolution Based on Codd’s paper Early commercial efforts focused on Unix First mainframe implementation by IBM - precursor to today’s DB2 First PC implementation in early 80’s by Oracle
  • 6. Relational Database Basics Storage Databases Tables Rows Columns Indexes Views Cursors Application interfaces
  • 8. Constraints Database Domain Uniqueness Relationship Cardinality 1 to 1 1 to N Other Business Rule Triggers Stored Procedures
  • 10. Database Management Systems Positioning Chart VLDB Enterprise Workgroup Single user Spreadsheet # Users Cost
  • 11. System Architecture Access MDB File Server Architecture Access
  • 12. System Architecture Oracle DB Visual Basic App Client/Server Architecture Access  SQL 
  • 13. System Architecture Oracle DB Browser Web Architecture Web Server  SQL 
  • 14. Approaching SQL Relatively simple Two main environments Interactive (This course) Embedded Static (Compiled) Dynamic
  • 15. SQL Standardization ANSI standardization First standard in 1986 SQL 89 SQL 92 SQL 99 Various vendor extensions Microsoft/Sybase: T-SQL Oracle: PL/SQL
  • 16. SQL Conformance Entry Intermediate Advanced Most are at least entry level
  • 17. SQL Statements Data Manipulation Language (DML) Data Control Language (DCL) Data Definition Language (DDL) Note: SQL 99 changes these to seven types
  • 18. SQL DDL Data definition language (DDL) Create, alter, drop, etc. Frequently implemented via various CASE tools: Visio, Embarcadero, ERWin, etc. But very useful for database administration
  • 19. SQL DCL Data Control Language (DDL) Grant Revoke Constraints
  • 20. SQL DML Data Manipulation Language (DML) Select Insert Update Delete
  • 21. SQL Statement Processing Parse Validate Optimize Access Plan Execute
  • 22. Bookstore Sample Database Before we continue (note: instructor may have already done this)… Load the sample database if you haven’t already Use Access import table feature, or Run SQL script, or Use Access upsizing wizard
  • 23. Text Conventions In Access character strings are normally surrounded by double quotes “ Jones” In an enterprise database such as Oracle or SQL Sever, then single quotes ‘ Jones’ Be sensitive to the environment of your class in copying scripts from the PowerPoint slides!
  • 24. Date Conventions In Access date are normally surrounded by pound signs #12/23/2004# In an enterprise database such as Oracle or SQL Sever, then single quotes ‘ 2004-12-23’ MySQL ’ 12-23-2004’ SQL Server ’ 23-DEC-04’ Oracle Be sensitive to the environment of your class in copying scripts from the PowerPoint slides!
  • 25. SELECT Basic Syntax ( Projection ): Select <column-list> or <*> From <table-list>
  • 26. SELECT Basic Example ( Projection ): select customer_last_name, customer_street from customers
  • 27. MS Access SQL Query
  • 28.  
  • 30. SELECT with Where Clause Example ( Restriction plus Projection ): Select <column-list> From <table-list> Where <selection-criteria>;
  • 31. SELECT with Where Basic Example ( Restriction plus Projection ): select customer_last_name, customer_street from customers where customer_last_name = “Jones”
  • 33. On Your Own Find books written by Mark Twain Show title, publisher, year
  • 34. Complex Predicates Follow normal boolean logic Select customer_last_name, customer_street From customers Where (customer_last_name = ‘Jones’ or customer_last_name = ‘Smith’)and customer_state=‘NY’
  • 37. Special Operators Can be used in where clause LIKE IN BETWEEN IS NULL
  • 38. Like (“Wild Card Matches”) ANSI Where customer_last_name like “Jo%” Like “Jo_” Access Where customer_last_name like “Jo*” Like “Jo?”
  • 39. IN Select * From customers Where customer_last_name in (“Rizzo”, “Jones”, “Garcia”) The list in parentheses can be replaced by a subquery. We will study this later.
  • 40. SQL Where Clause with IN
  • 41. IS NULL Select * From customers Where customer_street IS NULL SQL uses three valued logic. Must use IS NULL to test for unknowns. A null is NOT the same as blank or empty.
  • 42. On Your Own Find all customers with an address not equal to 4592 Maple Lane Was Peter Johnson selected? Why or why not?
  • 43. BETWEEN Select * From orders Where order_date BETWEEN #1/1/99# and #12/31/99# Note: date formats vary from product to product. Above is Access syntax, SQL Server uses single quotes. Ex: ‘1/1/99’
  • 45. Removing Duplicates Select DISTINCT customer_city From customers List once each city in which there are customers Removes duplicate rows from result set
  • 47. Sorting – ORDER BY DESC will sort in descending order Basic syntax : Select <column list> From <table list> Where <selection criteria> Order by <column list> [DESC]
  • 48. Sorting – ORDER BY Select * From customers Order by customer_state, customer_city Example: List all records sorted by state, city
  • 50. Selecting Top Records Select Top 5 (or top 25 percent) Customer_last_name , contact_zip From customers Order by customer_zip desc ; List largest 5 zips or top 25 % of them…
  • 51. SQL Exercises List all books whose publisher name begins with “H” or “T”; sort by title [hint: use LIKE] List all customers whose last name ends with “S”; sort by state, city, last name Find the order numbers of orders with order dates in 1999; sort by order #. [Hint: use BETWEEN] Find the order numbers and order dates of all orders with a “2” in column 2 of the credit card #; sort by order date descending [end module]