| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A simple relational database based on Stanford CS346 RedBase, implemented in elegant modern C++14.
Prepare a Linux / macOS machine, and clone this project to your local environment.
git clone https://github.com/li-plus/redbase-cpp && cd redbase-cppInstall dependencies of this project. We use CMake as the C++ build system. Flex & Bison are used to generate the SQL parser. libreadline helps us to build a user-friendly shell.
sudo apt install cmake flex bison libreadline-devThen build the project and make optional unittest.
mkdir -p build/ && cd build
cmake ..
make -j
make test # optionalNow start the RedBase shell and have fun!
./bin/redbase mydbThis 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.
Below is a quick demo of the supported main features.
create table student (id int, name char(32), major char(32));
create index student (id);
create table grade (course char(32), student_id int, score float);
create index grade (student_id);
show tables;
desc student;
insert into student values (1, 'Tom', 'Computer Science');
insert into student values (2, 'Jerry', 'Computer Science');
insert into student values (3, 'Jack', 'Electrical Engineering');
select * from student;
update student set major = 'Electrical Engineering' where id = 2;
select * from student;
delete from student where name = 'Jack';
select * from student;
insert into grade values ('Data Structure', 1, 90.0);
insert into grade values ('Data Structure', 2, 95.0);
insert into grade values ('Calculus', 2, 82.0);
insert into grade values ('Calculus', 1, 88.5);
select * from student, grade;
select id, name, major, course, score from student, grade where student.id = grade.student_id;
drop index student (id);
desc student;
drop table student;
drop table grade;
show tables;
exit;| Back | FazBrowse Home | New Git URL |