Backend Basics • Databases

How Databases Work — SQL Explained

Learn how databases store and organize information, and how SQL queries let you find exactly what you need.

Scroll to start

What Is a Database?

A database is like a digital filing cabinet. Instead of paper folders, it stores information in organized tables — rows and columns. Every row is a record, every column is a type of information.

Think of a spreadsheet. A database works the same way but is built for serious data — millions of rows, fast searches, and multiple people accessing it at once. When you log into an app, a database is probably answering questions like "is this username and password correct?"

users.csv
# A database table is just a structured list
id, name,               email,                    age
1,   Alice Chen,           alice@email.com,               28
2,   Marcus Johnson,        marcus@startup.io,             34
3,   Priya Patel,           priya@design.co,               26

Spreadsheet

  • Good for hundreds of rows
  • One person edits at a time
  • Basic search only
  • No connections between data

Database

  • Handles millions of rows
  • Multiple users simultaneously
  • Powerful queries in milliseconds
  • Links data across tables

Why Databases Are Everywhere

Every app you use runs on data. Your bank account, your email, your favorite game — all of it lives in databases. Understanding how they work helps you build apps that actually work with real information.

As a developer, you will write queries constantly. Whether you're building a dashboard, a user login system, or an e-commerce checkout — you're always reading from and writing to databases.

Key Insight

The entire internet runs on databases. Every post on social media, every product in an online store, every email in your inbox — stored, organized, and retrieved from a database. Understanding this one concept unlocks a huge part of how software works.

How a Query Gets Answered
💻
You Write
SQL query is written
🧠
Database
Finds matching rows
Returns
Results sent back
📋
Display
App shows data
milliseconds_

The Three Core SQL Commands

SQL — Structured Query Language — is how you talk to databases. Most of what you do boils down to three words: SELECT, INSERT, and UPDATE.

01
🔍

SELECT — Reading

SELECT pulls data out of the database. "Give me all users over age 25." It never changes data — it only reads and shows you what you asked for.

02

INSERT — Adding

INSERT adds new rows to a table. "Add this new user to the users table." New data goes in, existing data stays untouched.

03
✏️

UPDATE — Changing

UPDATE modifies existing rows. "Change this user's email address." It finds what you want and changes only those fields.

sql-queries.sql
-- Read data: get all users over 25
SELECT name, email FROM users WHERE age > 25;

-- Add a new user
INSERT INTO users (name, email, age)
VALUES ('Jordan Lee', 'jordan@email.com', 31);

-- Change someone's email
UPDATE users SET email = 'newemail@email.com'
WHERE name = 'Jordan Lee';

A Real-World Query

Imagine you run an online store. You want to find all orders over $100 placed in the last week, showing the customer's name and email so you can follow up.

store-query.sql
SELECT
    customers.name,
    customers.email,
    orders.total,
    orders.created_at
FROM orders
JOIN customers ON orders.customer_id = customers.id
WHERE
    orders.total > 100
    AND orders.created_at > '2026-03-25'
ORDER BY orders.total DESC;

Breaking It Down

JOIN connects two tables (orders and customers) using a shared ID. ORDER BY DESC shows the highest amounts first. AND adds a second condition. This one query answers a real business question in milliseconds.

Knowledge Check

Test what you learned about databases and SQL.

3 Questions

Question 01

What does a SELECT statement do?

Question 02

What is the purpose of a WHERE clause in a SQL query?

Question 03

What does a JOIN do in SQL?

🏆

You crushed it!

Perfect score on Databases and SQL.