Class 7 Prep

Databases Part 1

Up to now, you may have had the feeling that the apps we're building in the lessons, studios, and assignments don't seem that useful. If you thought harder about it, you may have determined that this is true because we don't have a way to store data over long periods of time. Actually, we haven't been able to store data for more than the duration of a single HTTP request, say, by adding an element to a list.

We're going to plug this functional hole across the next two lessons by learning how to store data in databases. In this lesson, we'll learn about relational databases, the most common way to store data, and SQL, the most common language used to access databases. We'll learn about tables, rows, and queries. We'll also learn about the similarities between Python objects and database tables.

In the next lesson, we'll learn how to manipulate databases locally using MAMP and phpMyAdmin, and we'll also learn more complex operations on databases.

Task Resource Type Link Instructions
Do Exercises w3schools SQL Tutorial Do all the lessons under SQL Tutorial from "SQL Home" through "SQL Comments". Stop when you get to the lessons under SQL Databases as we will work through most of these in the next lesson (and a select few are featured below - pun intended).
Do Interactive Course Khan Academy: Intro to SQL Complete all the lessons in: SQL basics, More advanced SQL queries, and Relational queries in SQL. This will give you an overview of how relational databases work as well as practice with common queries. Some of this content will overlap with what you learned in the w3schools tutorial above; that's okay - the added explanations and practice should help. Note that the UI is not wonderful, and the syntax checker can be finicky. Make sure you remember to use a semicolon ; to end all of your statements.
Do Exercise Create Table A brief explanation of how to create tables.
Do Exercise Drop Table A brief explanation of how to drop tables.
Do Exercise Foreign Key A brief explanation of foreign keys.
Read Article SQL: JOINS This Tech on the Net article is a worthwhile read if you find the idea of joins confusing. Joins are essential to understand and this article has Venn diagrams for the different joins, which is helpful for visualizing them.
Read Article One-to-Many Relationships This article will help you get an overview of the one-to-many concept in relational databases. We will explore this further in the studio.
Read Article Data Types in MySQL This article will help you understand the common data types in MySQL.