Learning / Web Basics / Chapter 2
Databases
Where applications keep their data and how you ask for it
What a database is, SQL vs. NoSQL, PostgreSQL, Redis & co., how indexes and transactions work, and your first SQL query, step by step.
Beginner · 11 slides · 11 min
What is a database?
A database is the program that keeps an application’s data safe and finds any piece of it again in milliseconds.
Tables, rows and columns
Relational databases store data in tables. Columns are properties, rows are records, and tables are linked by relations.
SQL and NoSQL
SQL databases split data into tables with a fixed structure. NoSQL databases store it in flexible shapes like documents or key-value pairs.
The differences at a glance
Structure, relations, consistency, scaling and query language: how SQL and NoSQL databases differ.
Databases you will meet
PostgreSQL, MySQL, SQLite, MongoDB, Redis and the enterprise classics, and what each one is good at.
How a database finds data so fast
Without an index a database checks row after row. With an index it jumps to the right row in a handful of steps.
Transactions: all or nothing
A transaction groups changes so that either all of them are saved or none. No money gets lost in a crash.
Your first query
SELECT, FROM, WHERE, ORDER BY: the four words that answer most questions you will ever ask a database.
Try it yourself
Run real SQL queries against a small customer table and see the results instantly.
Check yourself
Which database fits fast, short-lived session data?
Recap
Tables or documents, indexes, transactions and SQL: the database basics in five sentences.