Mini-DBMS

所属分类:数据库系统
开发工具:C++
文件大小:0KB
下载次数:0
上传日期:2022-12-28 11:07:39
上 传 者sh-1993
说明:  用C++编程语言实现的小型关系数据库管理系统(DBMS)
(A miniature relational database management system (DBMS) implemented using the C++ programming language)

文件列表:
.markdownlint.json (125, 2022-12-28)
CMakeLists.txt (346, 2022-12-28)
LICENSE (1064, 2022-12-28)
gui/ (0, 2022-12-28)
gui/Query_GUI/ (0, 2022-12-28)
gui/Query_GUI/CMakeLists.txt (1744, 2022-12-28)
gui/Query_GUI/CMakeLists.txt.user (29523, 2022-12-28)
gui/Query_GUI/main.cpp (172, 2022-12-28)
gui/Query_GUI/mainwindow.cpp (785, 2022-12-28)
gui/Query_GUI/mainwindow.h (373, 2022-12-28)
gui/Query_GUI/mainwindow.ui (1209, 2022-12-28)
gui/database_gui/ (0, 2022-12-28)
gui/database_gui/CMakeLists.txt (1771, 2022-12-28)
gui/database_gui/CMakeLists.txt.user (27277, 2022-12-28)
gui/database_gui/main.cpp (172, 2022-12-28)
gui/database_gui/mainwindow.cpp (223, 2022-12-28)
gui/database_gui/mainwindow.h (323, 2022-12-28)
gui/database_gui/mainwindow.ui (5687, 2022-12-28)
gui/screenshots/ (0, 2022-12-28)
gui/screenshots/ss_load_student.jpg (281968, 2022-12-28)
gui/screenshots/ss_qt_widget_app.jpg (127297, 2022-12-28)
gui/screenshots/ss_query_tab.jpg (213221, 2022-12-28)
presentation/ (0, 2022-12-28)
presentation/images/ (0, 2022-12-28)
presentation/images/Untitled 1.png (90612, 2022-12-28)
presentation/images/Untitled 2.png (37088, 2022-12-28)
presentation/images/Untitled 3.png (28567, 2022-12-28)
presentation/images/Untitled 4.png (27223, 2022-12-28)
presentation/images/Untitled 5.png (69585, 2022-12-28)
presentation/images/Untitled 6.png (101331, 2022-12-28)
presentation/images/Untitled 7.png (227108, 2022-12-28)
presentation/images/Untitled 8.png (90612, 2022-12-28)
presentation/images/Untitled 9.png (69585, 2022-12-28)
presentation/images/Untitled.png (325050, 2022-12-28)
presentation/images/cascaded_select.png (67326, 2022-12-28)
... ...

[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-c66648af7eb3fe8bc4f294546bfd86ef473780cde1dea487d3c4ff354943c9ae.svg)](https://classroom.github.com/online_ide?assignment_repo_id=9475714&assignment_repo_type=AssignmentRepo) # CSC3170 Course Project ## Project Overall Description This is our implementation for the course project of CSC3170, 2022 Fall, CUHK(SZ). For details of the project, you can refer to [project-description.md](project-description.md). In this project, we will utilize what we learned in the lectures and tutorials in the course, and implement either one of the following major jobs: - [ ] **Application with Database System(s)** - [x] **Implementation of a Database System** In this project, our group chooses Option 3 and creates a miniature relational database management system (DBMS) similar to [UCB CS61B, Fall 2014 project](https://inst.eecs.berkeley.edu/~cs61b/fa14/hw/proj1.pdf). Moreover, we adopt identical commands with the SQL language to achieve CRUD (Create, read, update and delete) operations on the tables. Our group decided to use C++ language instead of the original [Java templates in the CS61B project](https://inst.eecs.berkeley.edu/~cs61b/fa14/hw/code/proj1/). This means we have built our project from the ground up and make our own structure for organizing the repository and use different data structures as we see fit in the C++ language. ## Project Presentation Our team members have presented on our database's implementations and additional functions. The full video is publicly available at [this Bilibili link](https://www.bilibili.com/video/BV1jM41117Lt/). As a supplement, the pdf version of the slides is available at [this link](presentation/presentation.pdf). Because all our domestic team members are currently under COVID-19, after careful consideration about the condition of our presenters, we decided that all presenters in the zoom presentation can keep their camera off. ## Team Members Our team consists of the following members, listed in the table below (the team leader is shown in the first row, and is marked with behind his/her name): | Student ID | Student Name | Email | Github Username | | :----------: | :--------------: | :------------------------------: | :----------------:| | 120090727 | 李珈祺 | 120090727@link.cuhk.edu.cn | LJQ0727 | | 120090027 | 刘起 | 120090027@link.cuhk.edu.cn | LittleShaco | | 119030043 | 连珈玮 | 119030043@link.cuhk.edu.cn | jlianxm | | 120090874 | 杨亮 | 120090874@link.cuhk.edu.cn | yangbright-2001 | | 120040022 | Darren Boesono | darrenboesono28@gmail.com | dboesono | | 120040006 |Yohanes James | 120040006@link.cuhk.edu.cn | YohanesJames | | 120090231 |王茗萱 | 3096968424@qq.com | helloworldlgu | ### Task allocation for team members Please refer to [task-allocation.md](task-allocation.md) for the detailed task allocation throughout the process of building our project. ## Building and running the project We use `CMake` to build our project, which allows our Database implementation to have cross-platform support. First, please make sure your computer has `CMake` installed or install it [here](https://cmake.org/install/). If you're on a Windows machine, we recommand additionally installing MinGW following [this link](https://www.ics.uci.edu/~pattis/common/handouts/mingweclipse/mingw.html). - To build from source on macOS or linux, please go to the project root directory, then type the following commands on any terminal: ```bash mkdir build && cd build cmake .. make cd .. ``` - To build from source on Windows machines with MinGW installed, first go to the project root directory by `cd` into it, then type the following commands on PowerShell: ```bash mkdir build cd build cmake -G "MinGW Makefiles" .. mingw32-make cd .. ``` For Windows users, alternatively, if you have Visual Studio with Visual C++ installed, you could set the CMake to output a Visual Studio Solution file and open and build with Visual Studio. Here we do not illustrate this method further. - To run the executable file, first ensure your current directory is the project root directory, then run: ```bash cd build/simple_db ./simple_db cd ../.. ``` - To run the unit test, first ensure your current directory is the project root directory, then run: ```bash cd build/testing/unit_test ./simple_db_test cd ../.. ``` ## Project File structure The source codes for our Database Command-line implementation is located in the `simple_db` directory. Inside this directory, our header files are included in the `include` folder, and our `cpp` source files are included in the `src` folder. Here are the classes we have defined and their descriptions, with the class names same as the file names: - `Row` class: serves as the underlying storage unit for information about tables in the database, recording row information. - `SchemaItem` class: records tables’ schemas in the database. - `Table` class: A data structure that stores tables in a database. It contains three attributes, the rows (`Row` class) to record the row information, the schema (`SchemaItem` class) to record the schema, and the database (`Database` class) to record the database which the table belongs. It also contains some methods, such as insert, print, delete. - `CommandInterpreter` class: Used to accept and execute commands. Contains the specific implementation method of the command. (create, load, store, insert, print, select, delete, quit/exit…) - `Database` class: As a whole database, which contains instances of the Table and CommandInterpreter classes as attributes. `main.cpp`: This is the driver code for the application. ## Implementation details We adopt the object-oriented approach for our implementation. The following figure show the workflow of our database. ![Untitled](presentation/images/Untitled.png) To implement the specific database and related methods, we divide it into a number of classes, such as `Row` class, `SchemaItem` class, `Table` class, `CommandInterpreter` class and `Database` class. The `Row` class serves as the underlying storage unit for information about tables in the database, and it records row information. `SchemaItem` class is used to record tables’ schemas. Its structure and methods are similar to `Row` class. The class `Table` consists of row operations including getting, removing, and inserting the row. Furthermore, it is also used to print, load, and save the table. This table class will be used to construct the database class. The `database` class has several functionalities: add, remove, and get a table. Moreover, it also has functions to execute and save the database. For the `CommandInterpreter`, it is used to interpret the user input and execute the command to produce the desired result. It covers some standard syntaxes similar to SQL, such as create, delete, insert, select, load, store, print, etc. It first decomposes the command using the token variable with the function `tokenizer()`,(like the split() function in python), and then processes the parsed commands case by case. ## Command Specifications Here we list the commands our database supports. Like most Database Management Systems, our database supports SQL keywords written in uppercase, and they will have the same effect as the lowercase ones as listed below. - SQL - create new table: - create an empty table with the given name and column name: `create table (), (...)` - create a table with columns and contents produced by the select clause: `create table as