liveBook · Manning

B-tree

As explained in Grokking Relational Database Design

A B-tree is a self-balancing tree data structure that maintains sorted data and supports search, sequential access, insertion, and deletion in logarithmic time.

A B-tree is a self-balancing tree that keeps data sorted while supporting search, sequential access, insertion, and deletion in logarithmic time. Databases commonly use B-trees to implement indexes, giving queries fast access to rows by indexed column values instead of repeatedly sorting an entire table. section 7.9

Indexing movie ratings

Suppose a movie table contains millions of rows and the application often sorts or filters movies by rating. Creating `CREATE INDEX idx_rating ON movie (rating);` builds an index by scanning the table and recording rating values with pointers to their rows. Queries such as `WHERE rating = 5` or sorting by rating can then use the index. Primary-key columns are indexed automatically. section 7.9

How Grokking Relational Database Design covers it

How deep it goes
Defines balancing, ordering, supported operations, and logarithmic performance, then explains index construction without detailing tree internals.
Examples
Uses movie-rating searches, ordering queries, release-date indexes, and combined rating-and-date indexes.
What you can do after
Operate/configure it by creating database indexes that support frequently searched or sorted columns.
How it connects
Connects B-trees to database indexes, SQL queries, primary keys, composite indexes, and full-text indexes.

Also explained in

Compare how 4 books explain B-tree →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Relational Database Design. The section links point to the parts of the book it draws on.