{"id":21663003,"url":"https://github.com/lucapalminteri/simple-db","last_synced_at":"2026-05-14T13:33:18.587Z","repository":{"id":261342838,"uuid":"884008269","full_name":"LucaPalminteri/simple-db","owner":"LucaPalminteri","description":"This project is a minimal, custom-built relational database in C++ designed to store and manage simple data in a file-based system. It mimics the basic functionality of a SQL database by supporting operations such as inserting, displaying, and storing data in rows.","archived":false,"fork":false,"pushed_at":"2024-11-07T23:58:23.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T07:27:40.697Z","etag":null,"topics":["cpp","database","learning"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucaPalminteri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-06T01:02:54.000Z","updated_at":"2024-11-07T23:58:26.000Z","dependencies_parsed_at":"2025-01-25T07:34:55.474Z","dependency_job_id":null,"html_url":"https://github.com/LucaPalminteri/simple-db","commit_stats":null,"previous_names":["lucapalminteri/simple-db"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaPalminteri%2Fsimple-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaPalminteri%2Fsimple-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaPalminteri%2Fsimple-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaPalminteri%2Fsimple-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucaPalminteri","download_url":"https://codeload.github.com/LucaPalminteri/simple-db/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244560390,"owners_count":20472220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","database","learning"],"created_at":"2024-11-25T10:19:02.642Z","updated_at":"2026-05-14T13:33:13.492Z","avatar_url":"https://github.com/LucaPalminteri.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Database Server in C++\n\nThis project is a minimal, yet functional **SQL database server** written in C++ designed to handle basic SQL queries like `SELECT`, `INSERT`, `UPDATE`, and `DELETE`. The server accepts client requests, parses SQL queries, manipulates data, and stores it in files. The project aims to provide an educational, lightweight example of how a relational database system operates.\n\n## Features\n\n* **Basic SQL Command Support**: Handles common SQL commands such as `SELECT`, `INSERT`, `UPDATE`, and `DELETE`.\n* **Client-Server Architecture**: The server listens for incoming connections from clients and processes SQL queries in real-time.\n* **Data Storage**: Stores database tables and data on disk in a minimal format.\n* **Query Parsing**: Simple SQL query parsing to break down and interpret commands.\n* **Modular Design**: The project is organized into separate modules for networking, parsing, storage, and query execution.\n\n## Project Structure\n\n``` bash\n/simple-db/\n│\n├── /src/                  # All source code files\n│   ├── /core/             # Core database logic (e.g., query parsing, storage, indexing)\n│   ├── /network/          # Network-related code (e.g., server-client communication)\n│   ├── /parser/           # SQL query parser\n│   ├── /storage/          # Data storage and file management\n│   ├── /utils/            # Utility code (e.g., logging, error handling)\n│   ├── /commands/         # Specific SQL command implementations (SELECT, INSERT, etc.)\n│   ├── /tests/            # Unit tests for your components\n│   └── main.cpp           # Entry point for your application (server initialization)\n│\n├── /docs/                 # Project documentation (e.g., architecture, design decisions)\n├── /build/                # Build directory (generated when you build your project)\n│\n├── CMakeLists.txt         # CMake build configuration\n├── Makefile               # If you're using Makefile for build (optional)\n└── README.md              # Project description and setup guide\n```\n\n## Getting Started\n\n### Prerequisites\n\nBefore you begin, ensure you have the following installed:\n\n* **C++ Compiler**: A C++ compiler like GCC or Clang.\n* **CMake** (optional but recommended): A build system to manage the compilation process.\n\nTo check if you have `g++` installed, run:\n\n``` bash\ng++ --version\n```\n\nTo check if you have `CMake` installed, run:\n\n``` bash\ncmake --version\n```\n\n### Building the Project\n\n1. Clone the repository:\n\n    ``` bash\n    git clone https://github.com/your-username/simple-db.git cd simple-db\n    ```\n\n2. **Option 1: Using CMake**\n\n    Create a build directory and run CMake:\n\n    ``` bash\n    mkdir build cd build cmake .. make\n    ```\n\n3. **Option 2: Using Makefile** If you prefer using a Makefile, simply run:\n\n    ``` bash\n    make\n    ```\n\n4. The compiled executable will be in the `build/` directory.\n\n### Running the Server\n\nOnce the server is built, you can run it using the following command:\n\n``` bash\n./simple-db\n```\n\nThe server will start and listen for client connections on a predefined port (you can configure this in the code).\n\n## How to Use\n\n### SQL Queries\n\nThe database server supports the following basic SQL commands:\n\n* **SELECT**: Retrieve data from the database.\n\n    Example:\n\n    ``` sql\n    SELECT * FROM users;\n    ```\n\n* **INSERT**: Add new records to a table.\n\n    Example:\n\n    ``` sql\n    INSERT INTO users (id, name) VALUES (1, 'Luca');\n    ```\n\n* **UPDATE**: Modify existing records.\n\n    Example:\n\n    ``` sql\n    UPDATE users SET name = 'Jaz' WHERE id = 2;\n    ```\n\n* **DELETE**: Remove records from a table.\n\n    Example:\n\n    ``` sql\n    DELETE FROM users WHERE id = 3;\n    ```\n\n### Connecting to the Server\n\nTo connect to the server, you can use a **client program** or a **telnet session** to manually send SQL queries. The server listens for connections and processes queries from any client that connects.\n\n## Architecture\n\n### Core Components\n\n1. **Server**:\n\n    * The server is responsible for accepting client connections and managing their requests.\n    * It processes incoming queries and forwards them to the relevant components (like the parser, storage manager, etc.).\n2. **SQL Parser**:\n\n    * The parser takes the raw SQL query and breaks it down into structured components that can be understood and executed by the server.\n    * Example: A `SELECT` query is parsed into the table name and field list.\n3. **Storage Manager**:\n\n    * The storage manager is responsible for reading and writing data to disk. It handles the physical storage of tables and rows.\n    * Data is stored in simple text or binary files, with basic indexing for performance.\n4. **Command Handlers**:\n\n    * Each SQL command (e.g., `SELECT`, `INSERT`, `UPDATE`, `DELETE`) has a corresponding handler that knows how to execute it.\n    * The command handlers are responsible for interacting with the storage manager to manipulate data.\n\n## Testing\n\nUnit tests are included in the `/tests` folder. You can run the tests to ensure that the components work as expected.\n\n### Running Tests\n\n1. Navigate to the `/tests` directory.\n2. Compile the test files.\n3. Run the test executable to verify that all components function correctly.\n\n## Contributing\n\nIf you would like to contribute to this project, please fork the repository and submit a pull request with your proposed changes. Ensure that your changes are well-tested, and feel free to add new features or improve existing ones.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Acknowledgments\n\n* This project is built as part of an educational initiative to understand the internals of database systems.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucapalminteri%2Fsimple-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucapalminteri%2Fsimple-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucapalminteri%2Fsimple-db/lists"}