https://github.com/iamriteshkoushik/db-dev
My attempt to write a simple SQL database from build-your-own.org
https://github.com/iamriteshkoushik/db-dev
dbms golang sql systems-programming
Last synced: 7 months ago
JSON representation
My attempt to write a simple SQL database from build-your-own.org
- Host: GitHub
- URL: https://github.com/iamriteshkoushik/db-dev
- Owner: IAmRiteshKoushik
- Created: 2024-04-10T15:56:02.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-28T17:41:11.000Z (over 1 year ago)
- Last Synced: 2024-11-05T12:08:32.495Z (over 1 year ago)
- Topics: dbms, golang, sql, systems-programming
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Database Development
## Preliminary Notes
### 1. Persistence
A database will recover to a usable state when started after an unexpected
shutdown. While we can achieve it without a database as follows:
- Write the whole updated dataset to a file
- Call `fsync` on the new file
- Overwrite the old file by renaming the new file to the old file, which is
guarenteed by the file-systems to be atomic.
But this is only acceptable with a tiny dataset. Databases can do incremental
updates.
### 2. Indexing
There are two distinct types of database queries: analytical (OLAP) and
transactional (OLTP).
- Analytical (OLAP) queries typically involve a large amount of data, with
aggregation, grouping or join operations
- In contrast, transactional (OLTP) queries usually only touch a small amount
of indexed data. The most common types of queres are indexed point queries
and indexed range queries.
> Data structures that persist on disk to `look up` data are called `indexes`
in database systems. And database indexes can be larger than memory.
Common data structures include `B-Trees` and `LSM-Trees`
### 3. Concurrency
Modern applications do not do everything sequentially, and nor do databases.
There are different levels to concurrency :
- Concurrency between readers
- Concurrency between readers and writers
- Do writers need exclusive access to the database ?