TOPIC 22/3016 MINNOT STARTED

Databases for analysts: indexes, views, locks and transactions

Know what an index, a view and a transaction do, how locks keep writers apart, and which questions to ask when a report is slow or a change stops half way.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: a library. A card catalogue finds a book without a walk down every shelf. A glass case shows a chosen set of books and keeps no second copy. Borrowing rules stop two people taking the last copy.

Daily List is a made-up to-do app (SYNTHETIC / TRAINING ONLY). The Monday report is slow. Nina, the , asks Sam, the , what to do. Sam does not tune the database. He asks Leo, the developer, to show the plan.

What it is: (Structured Query Language) is a language for asking a database questions and for changing it. A table is a grid. A row is one task. A column is one fact, such as the title. A is a separate sorted structure the database uses to jump to matching rows instead of reading the whole table. A database view is a saved query that you use like a table, and it holds no rows of its own. A database transaction is a group of changes that the database saves all together, or not at all. You meet all three inside the database program, such as PostgreSQL or SQLite. A view's neighbour is a real table, which does store rows. A transaction's neighbour is one lone statement, which cannot undo a half-finished move.

Why it matters: Without an index, a large tasks table is read from the first row to the last, and Nina waits. Without a transaction, a move can finish one step and fail the next, so a task sits on the wrong list. Sam's job is to ask for the plan and to ask what happens if stops halfway.

One library desk serves a few readers. A database may serve many people at the same time.

PLAIN WORDS · 1 in this section
sqlite
a small free database tool

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the work.

THE REAL JOB The picture helps a newcomer remember that an index finds, a view shows and a transaction keeps a group of changes together.

  1. Ask for the plan
  2. Check the index
  3. Save a view
  4. Group the changes
  5. Let writers wait
Three database helpers

HOW THE PICTURE MAPS

How each part of the picture matches the work
In the pictureIn the work
The card catalogueA database index
The glass display case of chosen booksA database view
Borrowing a book and returning it as one visitA transaction
Waiting for the last copy to come backA lock
Walking every shelf to find a bookA sequential scan

WHERE THIS PICTURE STOPS

  • A library has one desk for a few readers, but a database may serve thousands at once.
  • A catalogue card is written once. An index must be updated on every change.
  • A display case holds real books. A view holds no data of its own.

HOOK

Find with the catalogue, show with the case, borrow by the rules.

REMEMBER IT THIS WAY

A chunk: a long list grouped so it is easier to hold.

Think library: the catalogue finds a book fast, the glass case shows chosen books, and borrowing rules make a visit all or none.

What each part of the trick stands for
In the trickWhat it stands for
CatalogueA database index finds rows without reading the whole table
Glass caseA database view is a saved query that shows chosen rows
Borrowing rulesA transaction saves all changes or none

TELL A FRIEND

An index helps the database find rows fast, a view is a saved query, and a transaction keeps a group of changes together. Locks make a second writer wait.

OFTEN MIXED UP WITH SQL for BAs: statement types, keys and constraints. That topic names the families of Structured Query Language () and the rules a table enforces. This one covers speed, saved queries and all-or-nothing changes.

PRACTISE AND KEEP

Sources for this topic — 10 sources
  1. Market practice

    CREATE INDEX (PostgreSQL documentation) ↗ — PostgreSQL Global Development Group · PostgreSQL 18, CREATE INDEX options and maintenance/concurrent build scope; publisher page opened6November 2026. Dialect scope explicit.

    CREATE INDEX options and maintenance/concurrent build scope. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: CREATE INDEX options and maintenance/concurrent build scope. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  2. Market practice

    CREATE VIEW (PostgreSQL documentation) ↗ — PostgreSQL Global Development Group · PostgreSQL 18, CREATE VIEW: ordinary query definition, not materialized result; publisher page opened6November 2026. Dialect scope explicit.

    CREATE VIEW: ordinary query definition, not materialized result. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: CREATE VIEW: ordinary query definition, not materialized result. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  3. Market practice

    Transactions (PostgreSQL tutorial) ↗ — PostgreSQL Global Development Group · PostgreSQL 18, §3.4 explicit transactions and savepoints; publisher page opened6November 2026. Dialect scope explicit.

    §3.4 explicit transactions and savepoints. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: §3.4 explicit transactions and savepoints. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  4. Market practice

    Transaction Isolation (PostgreSQL documentation, current version) ↗ — PostgreSQL Global Development Group · PostgreSQL 18, §13.2 isolation levels and Read Committed snapshots; publisher page opened6November 2026. Dialect scope explicit.

    §13.2 isolation levels and Read Committed snapshots. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: §13.2 isolation levels and Read Committed snapshots. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  5. Market practice

    Explicit locking, deadlocks (PostgreSQL documentation) ↗ — PostgreSQL Global Development Group · PostgreSQL 18, §13.3 row/table locking, deadlocks and ordinary-reader exceptions; publisher page opened6November 2026. Dialect scope explicit.

    §13.3 row/table locking, deadlocks and ordinary-reader exceptions. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: §13.3 row/table locking, deadlocks and ordinary-reader exceptions. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  6. Market practice

    SQLite: ON CONFLICT resolution ↗ — SQLite project · SQLite: ON CONFLICT resolution; Default ABORT undoes the failing statement, preserving earlier pending statements. Publisher page opened6November 2026.

    Default ABORT undoes the failing statement, preserving earlier pending statements. · Checked 2026-11-06

    Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.

  7. Market practice

    SQLite: query planning ↗ — SQLite project · SQLite: query planning; Index lookup and covering-index source figures5/14; query planner concepts, no promised runtime multiplier. Publisher page opened6November 2026.

    Index lookup and covering-index source figures5/14; query planner concepts, no promised runtime multiplier. · Checked 2026-11-06

    Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.

  8. Market practice

    PostgreSQL18: indexes on expressions ↗ — PostgreSQL Global Development Group · PostgreSQL 18: indexes on expressions; §11.7 expression index example lower(col), affected maintenance and non-HOT update scope. Publisher page opened6November 2026.

    §11.7 expression index example lower(col), affected maintenance and non-HOT update scope. · Checked 2026-11-06

    Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.

  9. Simplified educational illustration

    Payments Signal editorial teaching models — Payments Signal

    This site's own simplified teaching models. · Checked 2026-07-12

    What this simplifies: Daily List people, data and exercises are invented for teaching. Query results belong to the declared fixture and database version. Authorization, business identity, time bounds and unknown-value policy must be agreed in context; no universal mandatory query template is implied.

    Used wherever diagrams, scenarios, figures, or example values are didactic constructions rather than sourced facts; every such use carries a simplifications disclosure. All people, companies, banks, and list entries in examples are fictional.

  10. Market practice

    SQLite: public-domain dedication ↗ — SQLite project · SQLite copyright and public-domain declaration, publisher page opened 6 November 2026: basis for reusing the unchanged documentation figures shown in this lesson.

    Publisher explicitly dedicates all code and documentation to public domain; actual source reuse terms. · Checked 2026-11-06

    Publisher documentation opened on6November2026. Engine/version scope is explicit; other database implementations may differ. Teaching queries are synthetic, not a required publisher template.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.