Skip to content

r-moraru/cppDB

Repository files navigation

cppDB

A database management system with a simple UI.

New features:

  • Import and export table contents using .csv files
  • Index tables by adding a primary key to a table

How it works:

The UI is split into three tabs:

DBs - List of all databases created using this program.

Here you can create, delete or select a database.

Deleting a database:
In order to delete a database it first has to be empty - all tables must have been previously deleted from it.
Then, select the database by clicking its name from the list, and press the Delete DB button.

Selecting a database to work with:
To open a database to view its contents and alter it, simply click on its name from the list and press the Select DB button.

DB View - List of tables from selected database

After selecting a database, the DB View tab will be automatically opened.
Here you can create, delete or select a table.

Deleting a table:
In order to delete a table, you have to select it by clicking its name from the tables list and press on the Delete Table button.

Selecting a table:
Selecting a table works just like selecting a database. Click on its name and press the Select Table button.

Creating a new table:
Creating a new table can be done in two ways:

  1. by providing a .csv file containing the name of the columns optionally followed by a list of entries

    • Sample .csv file for a table containing two columns and initialized with three entries:

    • Column data types must be added manually. Maximum number of characters must also be specified for strings.

  2. by manually adding columns to the table

    • Adding a column that is also the primary key of the table:

    • Adding a column that is not the primary key of the table.
      Only one column can be the primary key of the table.

After creating these two tables and the associative table SongRef
that is used to add songs to playlists, the table list should look like this:

Table View - A canvas for viewing table description and search query results.

After selecting a table, the Table View tab will be automatically opened.
Rows can be inserted, selected, updated, and deleted from this tab.

Viewing table description:
Viewing the description of the current table can be done by pressing the View Table Data button.
This will populate the canvas with a list of the columns added to the table.
Each column has the following descriptors:

  • A boolean value, wether it is a primary key or not
  • A string, the name of the column
  • The data type of the column
  • The size in bytes occupied by the column on disk

Inserting rows from a .csv file:
Press the Insert Rows from .csv File button. This will open a dialogue box asking for a file. Select a file and press Open. The program will automatically insert all valid rows from the file.

Sample .csv file containing 6 rows

Inserting rows manually:
Pressing the Insert button will open a dialogue box asking for a new row to be inserted.
Each column value should be separated by whitespace. Strings sould not contain any whitespace characters.

Selecting rows from table:
In order to show all rows that satisfy a <column_name> = <value> condition, press the Select button.
This will open a dialogue box asking for <column_name> and <value>.
After filling the fields and pressing the Ok button, the canvas will be populated with the selected rows.

Updating rows from table:
If you want to update a column for certain rows of the table, press the Update button.
After filling the required fields, press the Ok button and the table will be updated.
Warning: Updating the primary key may be dangerous.
If the new value already exists, the entire updated row will be deleted.
This is because there can be no duplicates in the primary key column

Deleting rows from the table:
Deleting rows works similarly to selecting them. The program asks for a <column_name> - <value> pair.
All rows that satisfy the <column_name> = <value> condition will be deleted.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published