Skip to content

Commit 3519c11

Browse files
committed
Copy edits
1 parent 2a339b9 commit 3519c11

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- How does rolling back a transaction work?
66
- How are indexes formatted?
77
- When and how does a full table scan happen?
8-
- What format is a prepared statement save in?
8+
- What format is a prepared statement saved in?
99

1010
In short, how does a database **work**?
1111

part1.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# Part 1 - Introduction and Setting up the REPL
22

3-
As a web developer, I use relational databases every day at my job, but they were always a black box to me. Some questions I had:
3+
As a web developer, I use relational databases every day at my job, but they're a black box to me. Some questions I have:
44
- What format is data saved in? (in memory and on disk)
55
- When does it move from memory to disk?
66
- Why can there only be one primary key per table?
77
- How does rolling back a transaction work?
88
- How are indexes formatted?
99
- When and how does a full table scan happen?
10-
- What format is a prepared statement save in?
10+
- What format is a prepared statement saved in?
1111

12-
In other words, how does a database _work_?
12+
In other words, how does a database **work**?
1313

14-
To figure things out, I started writing a database from scratch. It's modeled off sqlite because it is designed to be small with fewer features than MySQL or PostgreSQL, so I have a better hope of understanding it. The entire database is stored in a single file!
14+
To figure things out, I'm writing a database from scratch. It's modeled off sqlite because it is designed to be small with fewer features than MySQL or PostgreSQL, so I have a better hope of understanding it. The entire database is stored in a single file!
1515

1616
# Sqlite
1717

18-
There's lots of documentation of [sqlite internals on their website](https://www.sqlite.org/arch.html), plus I've got a copy of [SQLite Database System: Design and Implementation](https://play.google.com/store/books/details?id=9Z6IQQnX1JEC).
18+
There's lots of [documentation of sqlite internals](https://www.sqlite.org/arch.html) on their website, plus I've got a copy of [SQLite Database System: Design and Implementation](https://play.google.com/store/books/details?id=9Z6IQQnX1JEC).
1919

2020
{% include image.html url="assets/images/arch1.gif" description="sqlite architecture (https://www.sqlite.org/zipvfs/doc/trunk/www/howitworks.wiki)" %}
2121

22-
A query goes through a chain of components in order to retrieve or modify data. The _front-end_ consists of the:
22+
A query goes through a chain of components in order to retrieve or modify data. The **front-end** consists of the:
2323
- tokenizer
2424
- parser
2525
- code generator
@@ -32,7 +32,7 @@ The _back-end_ consists of the:
3232
- pager
3333
- os interface
3434

35-
The **virtual machine** takes bytecode generated by the front-end as instructions. It can then issue operations on one or more tables or indexes, each of which is stored in a data structure called a B-tree. The VM is essentially a big switch statement on the type the bytecode instruction.
35+
The **virtual machine** takes bytecode generated by the front-end as instructions. It can then perform operations on one or more tables or indexes, each of which is stored in a data structure called a B-tree. The VM is essentially a big switch statement on the type the bytecode instruction.
3636

3737
Each **B-tree** consists of many nodes. Each node is one page in length. The B-tree can retrieve a page from disk or save it back to disk by issuing commands to the pager.
3838

@@ -153,7 +153,7 @@ db > .exit
153153
~
154154
```
155155

156-
Alright, we've got a working REPL. In the [next part](/part2) we'll start developing our command language. Meanwhile, here's the entire program from this part:
156+
Alright, we've got a working REPL. In [Part 2](/part2) we'll start developing our command language. Meanwhile, here's the entire program from this part:
157157

158158
```c
159159
#include <stdbool.h>

part2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Non-SQL statements like `.exit` are called "meta-commands". They all start with
5353

5454
Next, we add a step that converts the line of input into our internal representation of a statement. This is our hacky version of the sqlite front-end.
5555

56-
Lastly, we pass the prepared statement to `execute_statement`. This will eventually become our virtual machine.
56+
Lastly, we pass the prepared statement to `execute_statement`. This function will eventually become our virtual machine.
5757

5858
Notice that two of our new functions return enums indicating success or failure:
5959

0 commit comments

Comments
 (0)