Learning SQL
Upcoming SlideShare
Loading in...5

Like this? Share it with your network


Learning SQL

Uploaded on

Presented at PhillyDB ...

Presented at PhillyDB

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 36

http://coderwall.com 23
http://coreitpro.com 5
http://seanmcollins.com 3
http://www.coreitpro.com 2
http://www.python.org 2
http://www.seanmcollins.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n


  • 1. Beginning SQL Sean Collins
  • 2. Lesson PlanTheory Relational Algebra & SetsPractice SQL SQLiteSelf-Directed Learning
  • 3. TheorySet 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
  • 4. ExamplesUnionIntersectionSet-Difference
  • 5. Union
  • 6. Intersection
  • 7. Set-Difference
  • 8. Why This Is ImportantA whole branch of mathematics that dealswith collections of items and operations.SQL is just one of many ways to describecollections of items and operations.Learning to think about data as discrete setsof items opens new possibilities, because youare given new operations to manipulate sets.
  • 9. SQLStructured Query LanguageSQL is a language standard Different databases products have extra features tacked on to the languageUnderstand the structure of the language Everything else is just syntax
  • 10. SQLiteFree and Open Source relational database LIBRARYMost 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 CareAbout. All We Want Is SQL.
  • 12. The SQL Data ModelData in an SQL database Tables Columns Rows
  • 13. TablesTables are the “sets” of discourse in SQLTables contain data of the same type. Customers in a Customer table Orders in an Order table
  • 14. Theory To PracticePull up all of our customers, and theirorders. UNIONPull up all of our customers who have everordered something INTERSECTION
  • 15. ColumnsTables contain columns Columns can have different data types Dates Timestamps Integers Currency
  • 16. Digression: KeysMost data has a unique identifier, somewhere People: Social Security Numbers Groceries: UPC/Barcodes Cars: VINSQL has a data type to give hints to thedatabase engine about these unique identifiers
  • 17. KeysTypically a table will have a PRIMARY KEYOften, it is a automatically incrementedinteger Blog post #1 Blog post #2 ....
  • 18. Connecting Tables (Relations)Two tables can be related through the use ofFOREIGN KEYSCustomer table has a primary key (customer_id)Order table has a primary key (order_id) and acolumn (customer) that references the customertable.The SQL database now knows about this relation.
  • 19. Foreign Keys &Referential IntegrityForeign keys are used to enforceREFERENTIAL INTEGRITYYou cannot have an order for a customerthat doesn’t exist.You cannot delete a customer unless you alsodelete their orders.
  • 20. SQLite ExampleWe will now go through a hands-on exercisewith SQLite and the sample database fromGitHubA more complete example database can befound on the Chinook Project:http://chinookdatabase.codeplex.com/This is listed in Lesson_04.md of the GitHubproject