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



