Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
SQL
Why ‘Little Bobby Tables’ is funny
https://xkcd.com/327/
Hello!
I am Erik Tank
You can find me at @erik_tank
You can this talk at: https://github.com/skeletonkey/SQL_Intro
What is SQL?
• Structured Query Language
• ANSI (American National Standard Inst) standard*
• Allows for interactions with...
1970
“A Relational Model of Data for Large Shared Data Banks”
- Edgar Frank Codd
1970s
* SQL first developed (Raymond Boyc...
Databases consists of…
• Tables
• Collection of data
• Columns (attributes)
• Rows (values)
Collection of Data:
Sample DB
Normalization
vs
100% Normalized
Select Statement
Select Statement
Select Statement
Select Statement
Select Statement
Select Statement
Select Statement
Sub-queries
Explain Yourself!
Conditionals
• track_number = 1 or track_number = 2
• track_number in (1,2)
• track_number between 1 and 2
• name like ‘%w...
Insert
Update
Delete
Do’s and DON’Ts
• SANITIZE YOUR INPUTS!!!!!!
Do’s and DON’Ts
• SQL in code
Do’s and DON’Ts
• Schema is your contract
Do’s and DON’Ts
• Atomicity (ACID)
• begin transaction;
• rollback transaction;
• commit transaction;
Do’s and DON’Ts
• DELETE statements
• Test
• Test
• Test!!!!
DELETE
Do’s and DON’Ts
• Table names should be singular
• ID fields are just ‘id’
• Columns name should NOT be reserved words
• ‘...
Questions?
You can find me at @erik_tank
You can this talk at:
https://github.com/skeletonkey/SQL_Intro
Questions?
You can find me at @erik_tank
You can this talk at:
https://github.com/skeletonkey/SQL_Intro
Questions?
You can find me at @erik_tank
You can this talk at:
https://github.com/skeletonkey/SQL_Intro
Upcoming SlideShare
Loading in …5
×

SQL: Why 'Little Bobby Tables' is funny

A deck showing an intro to SQL from a programmers perspective.

  • Be the first to comment

  • Be the first to like this

SQL: Why 'Little Bobby Tables' is funny

  1. 1. SQL Why ‘Little Bobby Tables’ is funny https://xkcd.com/327/
  2. 2. Hello! I am Erik Tank You can find me at @erik_tank You can this talk at: https://github.com/skeletonkey/SQL_Intro
  3. 3. What is SQL? • Structured Query Language • ANSI (American National Standard Inst) standard* • Allows for interactions with databases • RDBMS (Relational DB Management System) • MySQL, ProstgreSQL, et.al
  4. 4. 1970 “A Relational Model of Data for Large Shared Data Banks” - Edgar Frank Codd 1970s * SQL first developed (Raymond Boyce, Donald Chamberlin) * Released to the public 1986 1st ANSI released Sources: https://www.businessnewsdaily.com/5804-what-is-sql.html SQL Primer by Rahul Batra (ISBN: 978-1-4842-3575-1)
  5. 5. Databases consists of… • Tables • Collection of data • Columns (attributes) • Rows (values)
  6. 6. Collection of Data:
  7. 7. Sample DB
  8. 8. Normalization vs
  9. 9. 100% Normalized
  10. 10. Select Statement
  11. 11. Select Statement
  12. 12. Select Statement
  13. 13. Select Statement
  14. 14. Select Statement
  15. 15. Select Statement
  16. 16. Select Statement
  17. 17. Sub-queries
  18. 18. Explain Yourself!
  19. 19. Conditionals • track_number = 1 or track_number = 2 • track_number in (1,2) • track_number between 1 and 2 • name like ‘%week%’ • name ilike ‘%WEEK%’ *
  20. 20. Insert
  21. 21. Update
  22. 22. Delete
  23. 23. Do’s and DON’Ts • SANITIZE YOUR INPUTS!!!!!!
  24. 24. Do’s and DON’Ts • SQL in code
  25. 25. Do’s and DON’Ts • Schema is your contract
  26. 26. Do’s and DON’Ts • Atomicity (ACID) • begin transaction; • rollback transaction; • commit transaction;
  27. 27. Do’s and DON’Ts • DELETE statements • Test • Test • Test!!!! DELETE
  28. 28. Do’s and DON’Ts • Table names should be singular • ID fields are just ‘id’ • Columns name should NOT be reserved words • ‘id’ field is ONLY for the DB • UUID field is ONLY for the user
  29. 29. Questions? You can find me at @erik_tank You can this talk at: https://github.com/skeletonkey/SQL_Intro
  30. 30. Questions? You can find me at @erik_tank You can this talk at: https://github.com/skeletonkey/SQL_Intro
  31. 31. Questions? You can find me at @erik_tank You can this talk at: https://github.com/skeletonkey/SQL_Intro

×