70 lines
No EOL
1.3 KiB
Text
Executable file
70 lines
No EOL
1.3 KiB
Text
Executable file
Assuming previously defined Attribute, compiled in a vector known as 'vec' and with subsequent numbers added
|
|
|
|
To create a table:
|
|
|
|
engine.createTable("table1", vec);
|
|
|
|
|
|
This creates a Relation object with the appropriate Attribute objects. It displays nothing.
|
|
|
|
To display the table:
|
|
|
|
engine.showTables(engine.getTableFromName("table1"));
|
|
|
|
|
|
This results in such output:
|
|
|
|
Display of relation--------------------------------
|
|
Relation name: table1
|
|
|
|
Attribute name: name
|
|
Elements: Fry Bender Leela Zoidberg
|
|
Attribute name: age
|
|
Elements: 22 5 22 50
|
|
|
|
|
|
With table3 having an equal domain to table1, this:
|
|
|
|
cout << engine.unionComp(engine.getTableFromName("table1"), engine.getTableFromName("table3"));
|
|
|
|
|
|
This will display:
|
|
|
|
1
|
|
|
|
|
|
To project a table's column:
|
|
|
|
engine.project((engine.getTableFromName("table1")), "name");
|
|
|
|
|
|
This will display:
|
|
|
|
-----------Initiated Query Projection---------
|
|
Column Title: name
|
|
Fry
|
|
Bender
|
|
Leela
|
|
Zoidberg
|
|
|
|
|
|
With an arbitrary vector of strings as cmds (until we are able to parse effectively):
|
|
|
|
engine.saveToFile(cmds);
|
|
|
|
|
|
This will result in a db file with the contents:
|
|
|
|
CREATE TABLE animals (name VARCHAR(20), kind VARCHAR(8), years INTEGER) PRIMARY KEY (name, kind);
|
|
|
|
SHOW animals;
|
|
|
|
|
|
|
|
//insert
|
|
|
|
//delete
|
|
|
|
//select
|
|
|
|
//product |