{"id":18382360,"url":"https://github.com/li-plus/redbase-cpp","last_synced_at":"2025-04-06T23:31:35.410Z","repository":{"id":40453500,"uuid":"337618901","full_name":"li-plus/redbase-cpp","owner":"li-plus","description":"A simple relational database based on Stanford CS346 RedBase, implemented in elegant modern C++14.","archived":false,"fork":false,"pushed_at":"2022-05-15T11:33:53.000Z","size":460,"stargazers_count":53,"open_issues_count":0,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T09:01:55.088Z","etag":null,"topics":["database","redbase","relational-database","sql"],"latest_commit_sha":null,"homepage":"https://web.stanford.edu/class/cs346/2015/redbase.html","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/li-plus.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}},"created_at":"2021-02-10T04:43:06.000Z","updated_at":"2025-03-18T08:43:28.000Z","dependencies_parsed_at":"2022-08-09T20:51:39.220Z","dependency_job_id":null,"html_url":"https://github.com/li-plus/redbase-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fredbase-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fredbase-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fredbase-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fredbase-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/li-plus","download_url":"https://codeload.github.com/li-plus/redbase-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247569123,"owners_count":20959758,"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":["database","redbase","relational-database","sql"],"created_at":"2024-11-06T01:04:43.040Z","updated_at":"2025-04-06T23:31:30.386Z","avatar_url":"https://github.com/li-plus.png","language":"C++","readme":"# RedBase-C++\n\n![Demo](fig/demo.gif)\n\nA simple relational database based on [Stanford CS346 RedBase](https://web.stanford.edu/class/cs346/2015/redbase.html), implemented in elegant modern C++14.\n\n## Features\n\n+ Indexing. We implement B+Tree index to accelerate single-table queries as well as table joins.\n+ Data Persistence. All changes to data are persistent on disk if the shell exits normally.\n+ SQL support. We support a subset of SQL, including basic DDL (`create table`, `drop table`, `create index`, `drop index`) and DML (`insert`, `delete`, `update`, `select`) statements.\n\n## Quick Start\n\nPrepare a Linux / macOS machine, and clone this project to your local environment.\n\n```sh\ngit clone https://github.com/li-plus/redbase-cpp \u0026\u0026 cd redbase-cpp\n```\n\nInstall dependencies of this project. We use CMake as the C++ build system. Flex \u0026 Bison are used to generate the SQL parser. `libreadline` helps us to build a user-friendly shell.\n\n```sh\nsudo apt install cmake flex bison libreadline-dev\n```\n\nThen build the project and make optional unittest.\n\n```sh\nmkdir -p build/ \u0026\u0026 cd build\ncmake ..\nmake -j\nmake test   # optional\n```\n\nNow start the RedBase shell and have fun!\n\n```sh\n./bin/redbase mydb\n```\n\nThis command creates a database named `mydb` for the first time, since it does not exist yet. On the next time, it will directly load the existing database `mydb`. To drop the database `mydb`, simply remove this folder by `rm -r mydb`.\n\n## Demo\n\nBelow is a quick demo of the supported main features.\n\n```sql\ncreate table student (id int, name char(32), major char(32));\ncreate index student (id);\ncreate table grade (course char(32), student_id int, score float);\ncreate index grade (student_id);\n\nshow tables;\ndesc student;\n\ninsert into student values (1, 'Tom', 'Computer Science');\ninsert into student values (2, 'Jerry', 'Computer Science');\ninsert into student values (3, 'Jack', 'Electrical Engineering');\n\nselect * from student;\nupdate student set major = 'Electrical Engineering' where id = 2;\nselect * from student;\ndelete from student where name = 'Jack';\nselect * from student;\n\ninsert into grade values ('Data Structure', 1, 90.0);\ninsert into grade values ('Data Structure', 2, 95.0);\ninsert into grade values ('Calculus', 2, 82.0);\ninsert into grade values ('Calculus', 1, 88.5);\n\nselect * from student, grade;\nselect id, name, major, course, score from student, grade where student.id = grade.student_id;\n\ndrop index student (id);\ndesc student;\n\ndrop table student;\ndrop table grade;\nshow tables;\n\nexit;\n```\n\n## Architecture\n\n![Architecture](fig/arch.svg)\n\n+ **Paged File Module (PF)** enables higher-level modules to perform efficient file I/O in terms of pages.\n+ **Record Management Module (RM)** manages the storage of unordered records.\n+ **Indexing Module (IX)** manages persistent indexes over unordered data records stored in record files.\n+ **System Management Module (SM)** handles the data definition language (DDL), including `create table`, `drop table`, `create index`, `drop index` statements.\n+ **Query Language Module (QL)** handles the data manipulation language (DML), including `insert`, `delete`, `update`, `select` statements.\n+ **SQL Parser** translates a raw SQL statement into an Abstract Syntax Tree (AST), which is further interpreted and executed by the controller.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fli-plus%2Fredbase-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fli-plus%2Fredbase-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fli-plus%2Fredbase-cpp/lists"}