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 OrmRanjan Kumar
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESNathRam2
 
Intro To DataBase
Intro To DataBaseIntro To DataBase
Intro To DataBaseDevMix
 
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
 
MS Access and Database Fundamentals
MS Access and Database FundamentalsMS Access and Database Fundamentals
MS Access and Database FundamentalsAnanda Gupta
 
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 Accessomoviejohn
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independenceapoorva_upadhyay
 
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 scenequest2900
 
It203 class slides-unit5
It203 class slides-unit5It203 class slides-unit5
It203 class slides-unit5Matthew Moldvan
 
Introduction to microsoft access
Introduction to microsoft accessIntroduction to microsoft access
Introduction to microsoft accessHardik Patel
 
Database Concepts and Terminologies
Database Concepts and TerminologiesDatabase Concepts and Terminologies
Database Concepts and TerminologiesOusman Faal
 

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

Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developerAhsan Kabir
 
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!Amanda Lam
 
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)Vidyasagar Mundroy
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredDanish Mehraj
 
SQL Interview Questions - InterviewBit.pdf
SQL Interview Questions - InterviewBit.pdfSQL Interview Questions - InterviewBit.pdf
SQL Interview Questions - InterviewBit.pdfAniket223719
 
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
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to databaseSuleman Memon
 
Physical elements of data
Physical elements of dataPhysical elements of data
Physical elements of dataDimara Hakim
 
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 SQLHarmony Kwawu
 

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

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Último (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

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