More Related Content

Recently uploaded(20)

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
  4. Examples Union Intersection Set-Difference
  5. Union
  6. Intersection
  7. Set-Difference
  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: This is listed in of the GitHub project

Editor's Notes

  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