Introduction
You might have wondered how you keep track of all your users’ data. Who remembers that your login password is CatLover1985
so you can sign into the website? The bottom layer of any web application is the database and it handles all the remembering for you (we’ll cover caching much later). It can be relatively simple, like an Excel spreadsheet, or incredibly complex and split into many giant pieces, like Facebook’s.
Databases are kind of hidden in the back of the web application, so people approach them with a sense of suspicion and awe. However, do not fret or feel intimidated. As you dive deeper into the subject, your databases and you are going to become very good friends (or at least frenemies). Rest assured, by the end of this curriculum, you’re going to understand what’s going on with your databases and be able to interact with them like a pro (and probably better than some people you’ll work with). This lesson is a teaser for that.
Compared to a normal programming language like you’ve already learned, SQL (Structured Query Language), which is used to query databases, has a very short syntax… with only a small handful of verbs to learn. What trips people up is that you need to be able to visualize in your head what it’s going to be doing. We’ll spend a fair bit of time on SQL and databases because they’re so fundamental, but for now we’ll just cover enough to get you familiar with what’s going on in there.
Lesson overview
This section contains a general overview of topics that you will learn in this lesson.
- What a database is.
- What relational databases are.
- In what way relational databases are different from XML.
- What SQL is.
- What SQL is used for.
- How to get all the records from a table in SQL.
- How to insert a record in SQL.
Assignment
- Check out this introduction of how SQL can be used to organise and manage an overwhelming amount of data.
- You do not need to go any further than the first page on introductions.
- Watch this short video introduction to relational databases to get a feel for why this stuff is useful and some more exposure to the terminology we’ll use.
- Go through this Khan Academy SQL tutorial to get a feel for actually creating and manipulating databases.
Knowledge check
The following questions are an opportunity to reflect on key topics in this lesson. If you can’t answer a question, click on it to review the material, but keep in mind you are not expected to memorize or master this knowledge.
Additional resources
This section contains helpful links to related content. It isn’t required, so consider it supplemental.
- What is a Relational Database? from HowStuffWorks.com
- A brief Simple Wiki article describing relational databases
- David J. Malan’s excellent SQL lecture and resources in Harvard’s CS50x.
- Relational databases aren’t the only way to store data. Non-relational (aka NoSQL) databases have emerged over the last couple decades. Check out this article to learn the difference between SQL and NoSQL.