Databases: an interactive database and SQL course
Databases is an interactive database course that goes from what a table is to joining tables with SQL and connecting a database to an app. Its 28 short sections cover tables, rows and columns, primary and foreign keys, SELECT queries with WHERE, sorting and limits, INSERT, UPDATE and DELETE, relationships, inner and outer joins, SQL vs NoSQL, schemas, migrations and ORMs.
Nearly every app keeps its data in a database, and SQL is the language most of them speak. Our what is SQL guide covers the language itself in more depth.
What the database course covers
| Sections | Topic | What you do |
|---|---|---|
| 1 to 3 | What a database is, and files vs databases | Pick the best way to store data for each scenario |
| 4 to 6 | Tables, rows, columns and primary keys | Choose the primary key for each table |
| 7 to 11 | SELECT, WHERE, ORDER BY and LIMIT | Write a SELECT query, then put the clauses of a query in order |
| 12 to 13 | INSERT, UPDATE and DELETE | Match each SQL command to what it does |
| 14 to 16 | Relationships and foreign keys | Read an entity relationship diagram, then name relationship types |
| 17 to 20 | INNER, LEFT and RIGHT JOIN | Pick the join for a description, then predict a join's result, NULLs included |
| 21 to 23 | SQL vs NoSQL and document databases | Decide which suits each scenario |
| 24 to 28 | Schemas, data types, migrations and ORMs | Match each layer between app and database to its job |
Tables and keys
A relational database stores data in tables: each row is one record and each column one piece of information, with a fixed data type. A primary key uniquely identifies each row. A foreign key in one table points at a primary key in another, which is how a database links each order to the customer who placed it.
Writing SQL
The middle of the course is SQL. You read data with SELECT, filter it with WHERE, sort it with ORDER BY and cap it with LIMIT, then change it with INSERT, UPDATE and DELETE, the operations often called CRUD. Joins combine tables: an INNER JOIN keeps only rows that match in both, while a LEFT JOIN keeps every row from the first table and fills gaps with NULL.
SELECT users.name, orders.total
FROM users
INNER JOIN orders ON orders.user_id = users.id
WHERE orders.total > 50
ORDER BY orders.total DESC;Choosing and managing a database
The last part steps back: when a document database (NoSQL) suits a project better than tables, how schemas and migrations change a database safely over time, and how an ORM such as Prisma lets your code work with the database without writing every query by hand.
Try a question from the course
No two rows can share a primary key value, and the value should never change. In a table of students with columns for name, date of birth, form group and student ID, two students can share a name, a birthday or a form, but no two share a student ID. So the student ID is the primary key.
Now pick the primary key for a new table, then press Mark to check your answer in the course.
Choose the primary key column for each table.
Press Mark to have your answer marked in the Databases course.
Who this course is for
- Beginners who want to understand how apps store data, and to read and write basic SQL.
- Computing students revising databases, primary and foreign keys and SQL queries.
- Web developers starting on the backend, who need relationships, joins and ORMs explained.
- Analysts and office workers who have outgrown spreadsheets.
What you need to know first
Nothing for the first two thirds: if you have used a spreadsheet, tables will feel familiar. The ORM and migration sections assume you have met a little code, which the HTML, CSS & JavaScript and APIs courses provide.
How long it takes
There are 28 sections and most take a few minutes. Learners without a plan can open two sections of a course a day, in order, so the whole course takes 14 days. A plan removes the daily limit and lets you go straight to any topic, such as joins.
Common questions
Is this database course free?
Does this course teach SQL?
What is the difference between a primary key and a foreign key?
What is the difference between an INNER JOIN and a LEFT JOIN?
Should I learn SQL or NoSQL?
What is an ORM?
Revision cards
Say the answer first, then flip the card to check it.
Where to go next
- Learn it
Databases
SQL, NoSQL and everything in between for storing and querying data
Start the course - Test it
GCSE Computer Science
A new exam-style paper every day, with instant marking and a mark scheme
Start today's paper - Test it
A-level Computer Science
A new exam-style paper every day, with instant marking and a mark scheme
Start today's paper