Developer Guide
Follow the instructions in the README of the RookDB/RookDB to run the Storage Engine. After the system starts, the interface will display a list of available operations to choose from.
The Storage Engine currently provides the following options:
Show Databases
Displays all databases available in the catalog with metadata (owner, creation timestamp).
Create Database
Creates a new database with metadata and updates the catalog.
Steps:
- Enter a database name when prompted
- Enter the owner name (or use the default)
- The database is registered in
pg_databaseand the data directory is created
Example:
Database name: users
Owner: admin
Select Database
Sets the active database for performing operations.
Steps:
- Enter a database name from the displayed list
Show Tables
Displays all tables in the selected database with statistics (row count, page count, creation timestamp).
Create Table
Creates a new table with a schema and optional constraints.
Steps:
- Enter table name
- Enter columns using format:
column_name:data_type[:constraint]
- Press Enter on an empty line to finish
Supported Types:
- INT (alias: INTEGER, INT32)
- BIGINT (alias: INT64)
- FLOAT (alias: REAL, FLOAT32)
- DOUBLE (alias: FLOAT64)
- BOOL (alias: BOOLEAN)
- TEXT (alias: STRING)
- VARCHAR(n)
- DATE
- TIMESTAMP
- BYTES (alias: BYTEA, BLOB)
Supported Inline Constraints:
PRIMARY KEY— unique, not-null constraint with a backing B-Tree indexNOT NULL— disallows NULL values
Example:
id:INT:PRIMARY KEY
name:TEXT:NOT NULL
email:VARCHAR(100)
After defining columns, you can also define table-level constraints such as composite primary keys and foreign keys.
Load CSV
Loads CSV data into an existing table. Constraint validation is performed during loading — rows that violate PRIMARY KEY, UNIQUE, FOREIGN KEY, or NOT NULL constraints are rejected.
Steps:
- Enter table name
- Enter CSV file path
Example:
examples/example.csv
Select Tuples
=============================
Choose an option:
...
8. Select tuples
...
=============================
Enter your choice: 7
Enter table name: employees
Enter SQL (single SELECT with WHERE): SELECT * WHERE id > 4
=== Tuples in 'company.employees' ===
Total pages: 3
id (INT) | name (VARCHAR(10))
Tuple 1: id=5 name='xJIsV'
Tuple 2: id=6 name='KzCIUYD'
Tuple 3: id=9 name='Alice'
=== End of tuples ===
Output Format
=== Tuples in '<db>.<table>' ===
Total pages: <num>
<col1_name> (<col1_type>) | <col2_name> (<col2_type>) | ...
Tuple 1: col1=<val> col2=<val> ...
Tuple 2: col1=<val> col2=<val> ...
...
=== End of tuples ===
- NULL values are printed as
colname=NULL. - Decode errors are printed as
<decode-error: ...>. - Tuple numbering is 1-based and continuous across the filtered results.
Show Table Statistics
Displays storage statistics like total number of pages.
Exit
Exit from RookDB.