fixing more things
This commit is contained in:
parent
38a4fdefe3
commit
1902e6f3d5
6 changed files with 53 additions and 1 deletions
|
@ -26,6 +26,11 @@ public:
|
|||
size++;
|
||||
}
|
||||
|
||||
string getElementAt(int pos)
|
||||
{
|
||||
return values[pos];
|
||||
}
|
||||
|
||||
vector<string> getValues() { return values; }
|
||||
string getName(){ return name; }
|
||||
string getType(){ return type; }
|
||||
|
|
23
OUTPUT.txt
23
OUTPUT.txt
|
@ -4,12 +4,14 @@ 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--------------------------------
|
||||
|
@ -20,6 +22,7 @@ This results in such output:
|
|||
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"));
|
||||
|
@ -29,6 +32,7 @@ This will display:
|
|||
|
||||
1
|
||||
|
||||
|
||||
To project a table's column:
|
||||
|
||||
engine.project((engine.getTableFromName("table1")), "name");
|
||||
|
@ -43,3 +47,22 @@ This will display:
|
|||
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 text 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
|
20
Relation.h
20
Relation.h
|
@ -47,6 +47,26 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
vector<int> findTuple(string attributeType, string type)
|
||||
{
|
||||
vector<int> tupleSlot; // tuples that have the attribute in question
|
||||
for (int i = 0; i < att.size(); ++i)// find attribute in question
|
||||
{
|
||||
if(att[i].getName() == attributeType)
|
||||
{
|
||||
for (int j = 0; j < att[i].getSize(); ++j)//search through all the values of the attribute column
|
||||
{
|
||||
if (att[i].getElementAt(j) == type)
|
||||
{
|
||||
tupleSlot.push_back(j);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return tupleSlot;
|
||||
}
|
||||
|
||||
string getTableName() {
|
||||
return name;
|
||||
}
|
||||
|
|
BIN
a.out
BIN
a.out
Binary file not shown.
2
savefile.txt
Normal file
2
savefile.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
CREATE TABLE animals (name VARCHAR(20), kind VARCHAR(8), years INTEGER) PRIMARY KEY (name, kind);
|
||||
SHOW animals;
|
4
test.cpp
4
test.cpp
|
@ -72,5 +72,7 @@ int main() {
|
|||
|
||||
vector<string> cmds;
|
||||
cmds.push_back("CREATE TABLE animals (name VARCHAR(20), kind VARCHAR(8), years INTEGER) PRIMARY KEY (name, kind);");
|
||||
cmds.push_back("SHOW animals");
|
||||
cmds.push_back("SHOW animals;");
|
||||
|
||||
engine.saveToFile(cmds);
|
||||
}
|
||||
|
|
Reference in a new issue