Welcome to SQL
About this video
Apps store their data in databases, programs that store data and let you add, modify and query it quickly. Relational databases store each kind of data in tables of rows (items) and columns (properties), and link tables, e.g. a user badges table that maps user IDs to badge IDs. SQL is the most popular language for creating tables, changing data and getting back the data you want.
You'll be able to
- explain what a database is and why apps use one.
- describe how a relational database table uses rows and columns.
- explain why a linking table that maps IDs is more efficient than repeating data.
- say what SQL is used for.
Key words
- database
- A program that stores data and lets you add, modify and query it quickly.
- relational database
- A popular type of database that stores each kind of data in a table and links tables together.
- table
- Data organised like a spreadsheet, with rows and columns.
- row
- One item in a table, such as one user.
- column
- A property of the items in a table, such as nickname or location.
- SQL
- A language designed for accessing databases: creating tables, changing data and querying it.
Transcript
- [Instructor] The world is full of data. Every app that you use is full of data. On Khan Academy, we store data about users and badges and progress. On Facebook they store data about who you are, who your friends are, and what they're posting. On Bank of America they store data about how much money you have and what accounts that's in.
How do these apps store data? Well, they use a database which is a program that helps store data and provides functionality for adding, modifying, and querying that data, and doing that all fast. Databases come in many forms, but a really popular type of database is called a relational database.
It stores each kind of data in a table, which is kind of like storing data in a spreadsheet. A row represents an item, and a column represents properties about that item. For example, to store data about Khan Academy users, we'd have a users table with a row for each user and columns for properties like their nickname and location.
Relational databases make it particularly easy to form relationships between tables. For example, in order to store Khan Academy users and their badges, we might have a users table and a badges table, and then a user badges table to remember which users earned which badges, just by mapping user IDs to badge IDs.
That's a more efficient form of storage than having to repeat everything about the user and everything about the badge in the user badges table. Most database come with a query language to interact with the database. SQL is a language designed entirely for accessing databases and is the most popular of them.
With SQL, we can create tables, change data, get back the data we're interested in. Like if we wanna find out which users joined in the last week or which users have a particular badge. That's what we're going to teach here. And you'll actually get to try out SQL here in the browser using SQL Lite, a particular implementation of it.
You won't be able to write the whole app here, but when you're done learning SQL, you'll have a much better understanding of how data is stored in the apps that you use and be able to use SQL if you ever build an app.
Video © Khan Academy, used under CC BY-NC-SA. Watch on Khan Academy. Puzzicle is not affiliated with Khan Academy.