{"id":26022753,"url":"https://github.com/heliolj/simple-database-in-c","last_synced_at":"2026-05-06T14:34:34.581Z","repository":{"id":279868751,"uuid":"940264625","full_name":"helioLJ/simple-database-in-c","owner":"helioLJ","description":"A lightweight SQLite clone written in C that implements B-trees, paging, and basic SQL operations. Educational project demonstrating core database concepts and low-level system programming.","archived":false,"fork":false,"pushed_at":"2025-02-28T00:17:28.000Z","size":11091,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T07:12:31.005Z","etag":null,"topics":["b-tree","c","database","sqlite"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helioLJ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-02-27T22:05:32.000Z","updated_at":"2025-02-28T00:17:31.000Z","dependencies_parsed_at":"2025-02-28T07:22:36.706Z","dependency_job_id":null,"html_url":"https://github.com/helioLJ/simple-database-in-c","commit_stats":null,"previous_names":["heliolj/simple-database-in-c"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helioLJ%2Fsimple-database-in-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helioLJ%2Fsimple-database-in-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helioLJ%2Fsimple-database-in-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helioLJ%2Fsimple-database-in-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helioLJ","download_url":"https://codeload.github.com/helioLJ/simple-database-in-c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242187807,"owners_count":20086224,"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":["b-tree","c","database","sqlite"],"created_at":"2025-03-06T10:19:19.359Z","updated_at":"2026-05-06T14:34:34.545Z","avatar_url":"https://github.com/helioLJ.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple SQLite Clone in C\n\nA lightweight SQLite-inspired database implementation in C, built for educational purposes. This project demonstrates fundamental database concepts including B-trees, paging, and basic SQL operations.\n\n## Demo\n\n![Database Demo](assets/images/demo.gif)\n\n## Features\n\n- Custom REPL (Read-Eval-Print Loop) interface\n- Basic SQL operations (INSERT and SELECT)\n- B-tree data structure for efficient data storage and retrieval\n- Persistent storage with a simple file-based approach\n- Memory management with paging system\n- Row-based storage format\n\n## Technical Specifications\n\n- Row Structure:\n  - ID (integer)\n  - Username (varchar, max 32 chars)\n  - Email (varchar, max 255 chars)\n- B-tree Implementation:\n  - Leaf nodes and internal nodes\n  - Automatic node splitting when full\n  - Parent pointer for tree traversal\n- Page size: 4096 bytes\n- Maximum pages: 100\n\n## Building the Project\n\nTo compile the project, use a C compiler (gcc recommended):\n\n```bash\ngcc -o db main.c\n```\n\n## Usage\n\n1. Start the database with a file name:\n```bash\n./db mydb.db\n```\n\n2. Available commands:\n```sql\n-- Insert a new record\ninsert 1 user1 user1@example.com\n\n-- Select all records\nselect\n\n-- Meta commands\n.exit      -- Exit the program\n.btree     -- Display the B-tree structure\n.constants -- Show internal constants\n```\n\n## Running Tests\n\nThe project includes RSpec tests. To run them:\n\n1. Install Ruby and RSpec\n2. Run the test suite:\n```bash\nrspec spec/main_spec.rb\n```\n\n## Project Structure\n\n- `main.c`: Main source code containing the database implementation\n- `spec/main_spec.rb`: Test specifications\n- `.gitignore`: Git ignore rules\n- `README.md`: This documentation file\n\n## Implementation Details\n\nThe database is implemented with the following key components:\n\n1. **Pager**: Handles reading/writing pages to disk\n2. **Table**: Manages the database structure\n3. **Cursor**: Abstracts the position in the table\n4. **B-tree**: Implements the tree data structure for storing rows\n5. **Node**: Represents leaf and internal nodes in the B-tree\n\n## Limitations\n\n- Fixed schema (id, username, email)\n- Basic SQL support (only INSERT and SELECT)\n- No DELETE or UPDATE operations\n- No transaction support\n- Maximum 100 pages\n\n## Contributing\n\nFeel free to submit issues and enhancement requests!\n\n## License\n\nThis project is open source and available under the MIT License.\n\n## Acknowledgments\n\nThis project is inspired by the [\"Let's Build a Simple Database\"](https://cstack.github.io/db_tutorial/) tutorial series by Connor Stack, implementing a SQLite clone from scratch in C. The tutorial provides an excellent step-by-step guide to understanding database internals by building one from the ground up. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheliolj%2Fsimple-database-in-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheliolj%2Fsimple-database-in-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheliolj%2Fsimple-database-in-c/lists"}