SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Similar 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
 

Similar 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

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
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
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
 
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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

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 del 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