Question: I need help fixing my code in c++. The problem is that the table isn't creating and it seems like my table functions aren't working

I need help fixing my code in c++. The problem is that the table isn't creating and it seems like my table functions aren't working correctly. Here is a pdf of the project and the SQL test case for this project. The expected output is in the sql test file. Below the PDF is my code that I need help fixing.

I need help fixing my code in c++. The problem is thatthe table isn't creating and it seems like my table functions aren't

Here is the code that I need help fixing.

One is the main.cpp file and the other is a table.h file.

=====main.cpp=====

#include #include #include #include #include #include #include

#include "table.h"

using namespace std;

void parseInput(const string& input, vector& commands); //parse commands with delimiter void parseCommands(vector& commands, vector

& tables); //execute commands and modify tables string getName(string line); //get name string getTblName(string line); //get table name string getData(string line); //get data

int main(int argc, char* argv[]){

string input; vector commands; vector

tables;

while (input != ".EXIT"){ //main loop cout "; getline(cin, input);

parseInput(input, commands); parseCommands(commands, tables); } return 0; }

//getData function, grabs data return line string getData(string line){ auto it = find(line.begin(), line.end(), '('); line = string(it, line.end()); line = line.substr(1, line.size() - 2); replace(line.begin(), line.end(), ',', '|');

return line; }

//getName functionk, gets name string getName(string line){ stringstream ss(line); string token; while (getline(ss, token, ' ')){ } return token; }

//getTblName, gets table name string getTblName(string line){ stringstream ss(line); string token; int i = 0; while (getline(ss, token, ' ') && i

//parseInput Function, gets token from data and pushes back void parseInput(const string& input, vector& commands){ stringstream ss(input); string token; while (getline(ss, token, ';')){ commands.push_back(token); } }

//parseCommands function, handles the database systems void parseCommands(vector& commands, vector

& tables){ string currDB;

for (auto i : commands){ if (i.find("CREATE DATABASE") != -1){ string dbName = getName(i); //grabs database name const int direrr = system(("mkdir " + dbName).c_str()); //makes directory if (direrr == 0) cout

auto it = find(tables.begin(), tables.end(), tb); //checks table exists if (it != tables.end()){ cout

size_t index = it - tables.begin(); //finds table index if it exists if (it != tables.end()){ cout

commands.clear(); }

=====table.h=====

#pragma once

#include #include

using namespace std;

class table{ private: string name; string db; string data;

public: table(string tbName, string currDB, string currData){ name = tbName; db = currDB; data = currData; }

table(string tbName, string currDB){ name = tbName; db = currDB; } string getName(){ return name; } string getData(){ return data; } void add(string line){ //puts add in substr line = line.substr(line.find("ADD") + 3); data.append(" | " + line); }

~table(){}

//operator overload to check for equality to see if table exists bool operator==(table const& rhs){ if (name == rhs.name && db == rhs.db) return true; else false; } };

In this assignment, you will write a program that allows a database user to manage the metadata of their relational data. By metadata, we mean the database's high-level information (e.g., database's name, creation time, owner) as well as the properties of the tables (e.g., table's names, attributes, constraints)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!