SimpleDB is a Go implementation of a basic database system, as described in the book "Database Design and Implementation" by Edward Sciore.
This project aims to create a simple, educational database system that demonstrates core concepts of database management systems. It includes components for file management, SQL parsing, query execution, and more.
- File-based storage: Each table and index is stored in separate files
- SQL parsing and execution
- Table scans and B-tree indexing
- Log management for recovery
- TCP server for client connections
SimpleDB currently supports the following data types:
- INT: Integer values
- VARCHAR: Variable-length character strings
Additional data types will be added in future updates to enhance the database's capabilities.
SimpleDB currently supports a subset of SQL statements. This list will expand as the project progresses:
- CREATE TABLE
- INSERT INTO
- SELECT
- UPDATE
- DELETE
- CREATE INDEX
- ORDER BY
More complex queries and additional SQL statements will be added in future updates.
- Go (version 1.22 or later)
- Clone the repository:
git clone https://github.com/yourusername/simpledb.git
- Navigate to the project directory:
cd simpledb
- Build the project:
go build ./cmd/simpledb
Run the SimpleDB server:
./simpledb
The server will start and listen on port 8765 by default.
Connect to the server using a TCP client (e.g., telnet):
telnet localhost 8765
You will be greeted with a welcome message and a prompt.
You can then enter SQL commands followed by a semicolon (;).
Example session:
Hello user! Thanks for using SimpleDB!
> CREATE TABLE users (id INT, name VARCHAR(20));
0
(5.69 ms)
> INSERT INTO users (id, name) VALUES (1, 'Alice');
1
(9.81 ms)
> SELECT id, name FROM users;
| id | name |
|----|---------|
| 1 | 'alice' |
---
1 record found.
(2.27 ms)
> exit
bye!
cmd/simpledb
: Main application entry pointsql
: SQL parsing and tokenizationrecord
: Record management and table operationslog
: Log management for recoveryfile
: File management for database storagetx
: Transaction and buffer management
This project is licensed under the MIT License.
- Edward Sciore for the book "Database Design and Implementation"
- All contributors to this project