一个简单数据库的实现
用C复现一个sqlite
翻译自:https://cstack.github.io/db_tutorial/
翻译水平有限,请对照原文。
数据库是如何工作的?
- 数据以什么样的格式存储在内存(memory)和磁盘(disk)上?
- 何时从内存转移到磁盘上?
- 为什么一个表(table)只能有一个主键(primary key)?
- 如何回滚事物(transaction)?
- 索引的格式是怎么样的?
- 何时以及如何进行全表扫描?
- 准备好的语句应该如何存储?
简而言之,一个数据库是如何工作的?
我正在使用C语言从头构建一个sqlite,为了方便理解,我将记录我的每个步骤。
目录
翻译中
- Part1 - REPL的简介和设置
- Part2 - 世上最简单的SQL编译器和虚拟机
- Part 3 - An In-Memory, Append-Only, Single-Table Database
- Part 4 - Our First Tests (and Bugs)
- Part 5 - Persistence to Disk
- Part 6 - The Cursor Abstraction
- Part 7 - Introduction to the B-Tree
- Part 8 - B-Tree Leaf Node Format
- Part 9 - Binary Search and Duplicate Keys
- Part 10 - Splitting a Leaf Node
- Part 11 - Recursively Searching the B-Tree
- Part 12 - Scanning a Multi-Level B-Tree
- Part 13 - Updating Parent Node After a Split