https://github.com/emmanuelmess/smalldb
A small database to test C++ writing values and a new architecture system
https://github.com/emmanuelmess/smalldb
architecture cpp cpp20 database
Last synced: 26 days ago
JSON representation
A small database to test C++ writing values and a new architecture system
- Host: GitHub
- URL: https://github.com/emmanuelmess/smalldb
- Owner: EmmanuelMess
- Created: 2022-06-19T15:45:54.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-19T15:58:43.000Z (almost 4 years ago)
- Last Synced: 2025-01-15T22:28:28.939Z (over 1 year ago)
- Topics: architecture, cpp, cpp20, database
- Language: C++
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SmallDB
A very simple database made with pure C++
## Types
* Double
* Long
* String (with max string length)
* Datetime (no timezone)
## Operations
* insertRow()
* find()
* readDouble(), writeDouble()
* readLong(), writeLong()
* readString(), writeString()
* readDatetime(), writeDatetime()
* delete()
## Architecture
The general arch is expressed in [architecture.txt](https://github.com/EmmanuelMess/SmallDB/blob/0436bdd5642b5b6e8bb3bbe5a8a2452b1bdb5cec/architecture.txt).
### File layout
|----------------|--------|-------|-------|-------|-------|-------|- -|
| number of rows | header | row 0 | row 1 | row 2 | row 3 | row 4 | ... |
|----------------|--------|-------|-------|-------|-------|-------|- -|
Header:
|---------------|------|-------------|------|-------------|- -|------------|
| header length | name | type letter | name | type letter | ... | row length |
|---------------|------|-------------|------|-------------|- -|------------|
* name is std::string_view::c_str() with unicode support
type letter:
|-----|-----------------| |-----| |-----| |-----|
| 'S' | max size column | or | 'D' | or | 'L' | or | 'T' |
|-----|-----------------| |-----| |-----| |-----|
* type letter is the id letter for Datatype
* max size column is the max size of the column in bytes, it is only used for String
Row:
|----------|----------|----------|- -|
| column 0 | column 1 | column 2 | ... |
|----------|----------|----------|- -|
* row has predefined length according to each type for Double, Long and Datetime
* if there is a string_view in the row, there will be length information in header
Serialization for Datetime:
|------|-------|-----|------|--------|--------|
| year | month | day | hour | minute | second |
|------|-------|-----|------|--------|--------|
year, month, day, hour, minute, second are saved as uint32_t
Serialization for string:
|- -|- -|
| characters | padding |
|- -|- -|
* pad with 0 until assigned string size is filled (for row skipping conveniences)
* All lengths are uint32_t
