AlgoViz
🗄️ Where the data really lives

Databases

An app forgets everything the moment it closes — unless it writes the data down somewhere that survives, stays organized, and never lies. That somewhere is a database. These lessons build the whole picture from zero: how data is shaped into tables, found in an instant instead of by searching everything, and kept correct even when a thousand people change it at the same moment.

  1. 1

    What is a database?

    Easy

    Your program forgets everything when it closes. A database is the notebook it writes things down in — one that stays organized and lets many people read it at once.

  2. 2

    The relational model

    Easy

    Data lives in tables — rows and columns, like a spreadsheet with rules. The trick is linking tables by id instead of copying details everywhere.

  3. 3

    What is SQL?

    Easy

    SQL is how you talk to a database. You describe WHAT you want — not how to fetch it — and the database figures out the rest.

  4. 4

    Normalization

    Medium

    One rule: store each fact in exactly one place, never copy it. Splitting a messy repeating table into tidy linked tables stops the data from disagreeing with itself.

  5. 5

    Keys & relationships

    Medium

    A primary key names each row uniquely; a foreign key points one table at another. Together they wire tables into the three shapes: one-to-many, many-to-many, one-to-one.

  6. 6

    Joins explained

    Medium

    A join glues two tables together by matching ids — so you can show each order WITH the buyer's name. INNER keeps only matches; LEFT keeps everything on the left, filling blanks.

  7. 7

    ACID transactions

    Medium

    A transaction groups several steps so they ALL happen or NONE do. The four letters — ACID — are the promises that keep your data correct even when the power dies mid-update.

  8. 8

    Isolation levels

    Hard▶ has animation

    The 'I' in ACID is a dial. Crank it up and transactions never see each other's mess (safe but slow); turn it down and they go faster but can read half-done or shifting data.

  9. 9

    Concurrency control

    Hard

    HOW the database stops two writers from clobbering each other. Two playbooks: locking (grab the row, others wait) and MVCC (everyone edits their own snapshot, conflicts checked at commit).

  10. 10

    Deadlock in databases

    Hard

    Two transactions each hold a lock the other needs — both stuck forever. The database spots the wait-for cycle and breaks it by killing one transaction (the 'victim') and rolling it back.

  11. 11

    How indexes work (B-trees)

    Medium▶ has animation

    An index isn't just a sorted list — it's a B-tree: a short, bushy, always-balanced tree where finding a row touches only a few levels, even over a billion rows.

  12. 12

    How a query runs

    Medium▶ has animation

    You write WHAT you want; the database figures out HOW. It turns your SELECT into a step-by-step plan and picks the cheapest path to the answer.

  13. 13

    SQL vs NoSQL

    Medium

    Strict tables with strong guarantees, or flexible documents that scale wide? Not 'which is better' — a real decision about your data.

  14. 14

    Design: a social feed schema

    Hard

    Model a tiny social app end to end — users, posts, likes, follows — and watch every key, relationship, and index you learned snap into place.