SlideShare uma empresa Scribd logo
1 de 20
Beginning SQL
   Sean Collins
Lesson Plan
Theory

  Relational Algebra & Sets

Practice

  SQL

  SQLite

Self-Directed Learning
Theory

Set Theory

  The branch of mathematics that deals
  with the formal properties of sets as
  units (without regard to the nature of
  their individual constituents) and the
  expression of other branches of
  mathematics in terms of sets
Examples


Union

Intersection

Set-Difference
Union
Intersection
Set-Difference
Why This Is Important

A whole branch of mathematics that deals
with collections of items and operations.

SQL is just one of many ways to describe
collections of items and operations.

Learning to think about data as discrete sets
of items opens new possibilities, because you
are given new operations to manipulate sets.
SQL

Structured Query Language

SQL is a language standard

  Different databases products have extra
  features tacked on to the language

Understand the structure of the language

  Everything else is just syntax
SQLite
Free and Open Source relational database LIBRARY

Most SQL products are considered a “RDBMS”

  Relational Database Management System

  Which means they contain extra functionality

     Networking

     Backups

     Authentication

     Etc....
Things We Don’t Care
About. All We Want Is
         SQL.
The SQL Data Model


Data in an SQL database

  Tables

    Columns

       Rows
Tables


Tables are the “sets” of discourse in SQL

Tables contain data of the same type.

  Customers in a Customer table

  Orders in an Order table
Theory To Practice

Pull up all of our customers, and their
orders.

  UNION

Pull up all of our customers who have ever
ordered something

  INTERSECTION
Columns
Tables contain columns

  Columns can have different data types

     Dates

     Timestamps

     Integers

     Currency
Digression: Keys

Most data has a unique identifier, somewhere

  People: Social Security Numbers

  Groceries: UPC/Barcodes

  Cars: VIN

SQL has a data type to give hints to the
database engine about these unique identifiers
Keys

Typically a table will have a PRIMARY KEY

Often, it is a automatically incremented
integer

  Blog post #1

  Blog post #2

  ....
Connecting Tables
        (Relations)
Two tables can be related through the use of
FOREIGN KEYS

Customer table has a primary key (customer_id)

Order table has a primary key (order_id) and a
column (customer) that references the customer
table.

The SQL database now knows about this relation.
Foreign Keys &
Referential Integrity
Foreign keys are used to enforce
REFERENTIAL INTEGRITY

You cannot have an order for a customer
that doesn’t exist.

You cannot delete a customer unless you also
delete their orders.
SQLite Example
We will now go through a hands-on exercise
with SQLite and the sample database from
GitHub

A more complete example database can be
found on the Chinook Project:

http://chinookdatabase.codeplex.com/

This is listed in Lesson_04.md of the GitHub
project

Mais conteúdo relacionado

Mais procurados

01 Persistence And Orm
01 Persistence And Orm01 Persistence And Orm
01 Persistence And Orm
Ranjan Kumar
 
MS Access – Part 1 (One Day Workshop)
MS Access – Part 1 (One Day Workshop)MS Access – Part 1 (One Day Workshop)
MS Access – Part 1 (One Day Workshop)
Khader Shaik
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independence
apoorva_upadhyay
 
It203 class slides-unit5
It203 class slides-unit5It203 class slides-unit5
It203 class slides-unit5
Matthew Moldvan
 
Introduction to microsoft access
Introduction to microsoft accessIntroduction to microsoft access
Introduction to microsoft access
Hardik Patel
 

Mais procurados (20)

01 Persistence And Orm
01 Persistence And Orm01 Persistence And Orm
01 Persistence And Orm
 
CIS 145 test 1 review
CIS 145 test 1 reviewCIS 145 test 1 review
CIS 145 test 1 review
 
Introduction to Oracle
Introduction to OracleIntroduction to Oracle
Introduction to Oracle
 
Introduction to ms access
Introduction to ms accessIntroduction to ms access
Introduction to ms access
 
Ms access
Ms accessMs access
Ms access
 
MS Access Training
MS Access TrainingMS Access Training
MS Access Training
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
 
Intro To DataBase
Intro To DataBaseIntro To DataBase
Intro To DataBase
 
Introduction - Database (MS Access)
Introduction - Database (MS Access)Introduction - Database (MS Access)
Introduction - Database (MS Access)
 
MS ACCESS
MS ACCESSMS ACCESS
MS ACCESS
 
Sql
SqlSql
Sql
 
Database intro
Database introDatabase intro
Database intro
 
MS Access – Part 1 (One Day Workshop)
MS Access – Part 1 (One Day Workshop)MS Access – Part 1 (One Day Workshop)
MS Access – Part 1 (One Day Workshop)
 
MS Access and Database Fundamentals
MS Access and Database FundamentalsMS Access and Database Fundamentals
MS Access and Database Fundamentals
 
Microsoft Access 2007: Get To Know Access
Microsoft Access 2007: Get To Know AccessMicrosoft Access 2007: Get To Know Access
Microsoft Access 2007: Get To Know Access
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independence
 
Access tips access and sql part 1 setting the sql scene
Access tips  access and sql part 1  setting the sql sceneAccess tips  access and sql part 1  setting the sql scene
Access tips access and sql part 1 setting the sql scene
 
It203 class slides-unit5
It203 class slides-unit5It203 class slides-unit5
It203 class slides-unit5
 
Introduction to microsoft access
Introduction to microsoft accessIntroduction to microsoft access
Introduction to microsoft access
 
Database Concepts and Terminologies
Database Concepts and TerminologiesDatabase Concepts and Terminologies
Database Concepts and Terminologies
 

Semelhante a Learning SQL

Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…
Aaron Shilo
 
Physical elements of data
Physical elements of dataPhysical elements of data
Physical elements of data
Dimara Hakim
 

Semelhante a Learning SQL (20)

T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
Sqlite
SqliteSqlite
Sqlite
 
Physical Design and Development
Physical Design and DevelopmentPhysical Design and Development
Physical Design and Development
 
Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developer
 
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
Waiting too long for Excel's VLOOKUP? Use SQLite for simple data analysis!
 
Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)
 
SQL cheat sheet.pdf
SQL cheat sheet.pdfSQL cheat sheet.pdf
SQL cheat sheet.pdf
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
Bt0066 dbms
Bt0066 dbmsBt0066 dbms
Bt0066 dbms
 
SQL Interview Questions - InterviewBit.pdf
SQL Interview Questions - InterviewBit.pdfSQL Interview Questions - InterviewBit.pdf
SQL Interview Questions - InterviewBit.pdf
 
Dbms slide share.pptx
Dbms slide share.pptxDbms slide share.pptx
Dbms slide share.pptx
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
E-R diagram & SQL
E-R diagram & SQLE-R diagram & SQL
E-R diagram & SQL
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…
 
Sq lite module5
Sq lite module5Sq lite module5
Sq lite module5
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Metadata Creation In OBIEE
Metadata Creation In OBIEEMetadata Creation In OBIEE
Metadata Creation In OBIEE
 
Physical elements of data
Physical elements of dataPhysical elements of data
Physical elements of data
 
Introduction to the Structured Query Language SQL
Introduction to the Structured Query Language SQLIntroduction to the Structured Query Language SQL
Introduction to the Structured Query Language SQL
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

Learning SQL

  • 1. Beginning SQL Sean Collins
  • 2. Lesson Plan Theory Relational Algebra & Sets Practice SQL SQLite Self-Directed Learning
  • 3. Theory Set Theory The branch of mathematics that deals with the formal properties of sets as units (without regard to the nature of their individual constituents) and the expression of other branches of mathematics in terms of sets
  • 8. Why This Is Important A whole branch of mathematics that deals with collections of items and operations. SQL is just one of many ways to describe collections of items and operations. Learning to think about data as discrete sets of items opens new possibilities, because you are given new operations to manipulate sets.
  • 9. SQL Structured Query Language SQL is a language standard Different databases products have extra features tacked on to the language Understand the structure of the language Everything else is just syntax
  • 10. SQLite Free and Open Source relational database LIBRARY Most SQL products are considered a “RDBMS” Relational Database Management System Which means they contain extra functionality Networking Backups Authentication Etc....
  • 11. Things We Don’t Care About. All We Want Is SQL.
  • 12. The SQL Data Model Data in an SQL database Tables Columns Rows
  • 13. Tables Tables are the “sets” of discourse in SQL Tables contain data of the same type. Customers in a Customer table Orders in an Order table
  • 14. Theory To Practice Pull up all of our customers, and their orders. UNION Pull up all of our customers who have ever ordered something INTERSECTION
  • 15. Columns Tables contain columns Columns can have different data types Dates Timestamps Integers Currency
  • 16. Digression: Keys Most data has a unique identifier, somewhere People: Social Security Numbers Groceries: UPC/Barcodes Cars: VIN SQL has a data type to give hints to the database engine about these unique identifiers
  • 17. Keys Typically a table will have a PRIMARY KEY Often, it is a automatically incremented integer Blog post #1 Blog post #2 ....
  • 18. Connecting Tables (Relations) Two tables can be related through the use of FOREIGN KEYS Customer table has a primary key (customer_id) Order table has a primary key (order_id) and a column (customer) that references the customer table. The SQL database now knows about this relation.
  • 19. Foreign Keys & Referential Integrity Foreign keys are used to enforce REFERENTIAL INTEGRITY You cannot have an order for a customer that doesn’t exist. You cannot delete a customer unless you also delete their orders.
  • 20. SQLite Example We will now go through a hands-on exercise with SQLite and the sample database from GitHub A more complete example database can be found on the Chinook Project: http://chinookdatabase.codeplex.com/ This is listed in Lesson_04.md of the GitHub project

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n