Question

In: Computer Science

C++ Implement the following code: More Info added: Database: Generally, a user should instantiate a single...

C++

Implement the following code:

More Info added:

Database:

Generally, a user should instantiate a single database object and work from there. The database object should include commands to do the following:

 You should allow a constructor function with no arguments (other constructors may be included if desired). This creates an “empty” database.

 An add table function that takes a single table object and a name, and adds that table to the database.

 A drop function that takes a table name and deletes it from the database

 * A save function that takes a file name and saves the database to that file (save format is entirely up to you).

 * A load function that takes in a file name and loads in a database from that file. Any existing database should be deleted.

 * A merge function that allows another database to be merged into that one.

 * A copy function that copies an entire database.

 A list table function that returns a list of all table names in the database

 A get tables function that returns all the tables in the database.

 A query function (described below, separately)

 * A delete command. The structure of the delete command should follow that of the query command, except that instead of returning a table, the table in the FROM portion has the appropriate tuples deleted.

 * An update/modify command. The modify command should take a table name, a WHERE clause (as in the query command), and a SET clause. The SET clause should be able to reference attributes of the table, and set them to values that are either a constant or (in the case integers and floats) a computed function on attribute values (from that table). The operations +, - , *, and / should be supported. Note that there are multiple ways to handle a returned list of names or the tables. For instance, you might use an array, or a vector, or you might return a set or some other container.

Note: Don't use map, please vectors only.

[Code]

#include "database.h"

Database::Database(){

}


Database::Database(vector Tables){
  

}

//Add a table to the database

//Ownership of the table is permanently transferred to the database, and it will be destroyed when the database is destroyed.

//Throws an \a InvalidOperationError if \a name already exists in the database

//param name what to call the table in the database

void Database::add_Table(string table_name, Table tab){
  
}

//Remove a table from the database.

//The table is destroyed with 'delete' when this function is called.

//Throws a \a TableDoesNotExistError if \a name does not exist in the database.

//param name which table to remove from the database

//returns A pointer to the Table, which can now be destroyed

void Database::drop_Table(string table_name){

}

/*

Save the database to a file,

Throws an \a IOError on failture.

\param filename the output fie

*/
void Database::save(string filename){

}

/*

Load a database from a file, this will clear any existing records

Throws an \a IOError on failture.

\param filename the input file

*/
void Database::load(string filename){

}

/*

Merge another database into this one.

Tables in this database are overwritten by tables in \a database.

\param database The database that you want to merge into this one.

*/
void Database::merge(const Database& database){

}

/**

Make a copy of this database

\returns a one-for-one copy / clone of this database

**/
Database Database::copy(){

}

//Returns a list of all the tables currently in the database
vector Database::list_Tables(){

}

//Returns the table named *table_Name* in the database.

//Throws a \a TableDoesNotExistError if \a table_Name does not exist in the database
vector

* Database::getTables(){
  
}

/****

//Perform a query on the database

//Throws a \a TableDoesNotExistError if \a from does not exist.

//Throws a \a QuerySyntaxError if \a select or \a where have a syntax error.

\param select which columns to include in the returned Table

\param from which table to query from

\param where the conditions for the query from

\return A pointer to Table with all of the records that match the query

**/
Table Database::query(string select, string from, string where){


}

/******

Delete all records that match the query

Throws a \a TableDoesNotExistError if \a from does not exist.

Throws a \a QuerySyntaxError if \a where has a syntax error.

\param from which table to query from

\param where the conditions for the query to match

******/
void Database::delete_From(string from, string where){

}

//********

Must modify the records in table.

Throws a \a TableDoesNotExistError if \a table does not exist

Throws a \a QuerySyntaxError if \a where or \a set have a syntax error

\param table_name name of the table to update records in

\param where a SQL where clause to find records in the table

\param set a SQL set clause

*****************//

void Database::update(string table_Name, string where, string set){

}

[/EndCode]

Solutions

Expert Solution

#include "database.h"

Database::Database(){

}


Database::Database(vector Tables){
  

}

//Add a table to the database

//Ownership of the table is permanently transferred to the database, and it will be destroyed when the database is destroyed.

//Throws an \a InvalidOperationError if \a name already exists in the database

//param name what to call the table in the database

void Database::add_Table(string table_name, Table tab){
  
}

//Remove a table from the database.

//The table is destroyed with 'delete' when this function is called.

//Throws a \a TableDoesNotExistError if \a name does not exist in the database.

//param name which table to remove from the database

//returns A pointer to the Table, which can now be destroyed

void Database::drop_Table(string table_name){

}

/*

Save the database to a file,

Throws an \a IOError on failture.

\param filename the output fie

*/
void Database::save(string filename){

}

/*

Load a database from a file, this will clear any existing records

Throws an \a IOError on failture.

\param filename the input file

*/
void Database::load(string filename){

}

/*

Merge another database into this one.

Tables in this database are overwritten by tables in \a database.

\param database The database that you want to merge into this one.

*/
void Database::merge(const Database& database){

}

/**

Make a copy of this database

\returns a one-for-one copy / clone of this database

**/
Database Database::copy(){

}

//Returns a list of all the tables currently in the database
vector Database::list_Tables(){

}

//Returns the table named *table_Name* in the database.

//Throws a \a TableDoesNotExistError if \a table_Name does not exist in the database
vector

* Database::getTables(){
  
}

/****

//Perform a query on the database

//Throws a \a TableDoesNotExistError if \a from does not exist.

//Throws a \a QuerySyntaxError if \a select or \a where have a syntax error.

\param select which columns to include in the returned Table

\param from which table to query from

\param where the conditions for the query from

\return A pointer to Table with all of the records that match the query

**/
Table Database::query(string select, string from, string where){


}

/******

Delete all records that match the query

Throws a \a TableDoesNotExistError if \a from does not exist.

Throws a \a QuerySyntaxError if \a where has a syntax error.

\param from which table to query from

\param where the conditions for the query to match

******/
void Database::delete_From(string from, string where){

}

//********

Must modify the records in table.

Throws a \a TableDoesNotExistError if \a table does not exist

Throws a \a QuerySyntaxError if \a where or \a set have a syntax error

\param table_name name of the table to update records in

\param where a SQL where clause to find records in the table

\param set a SQL set clause

*****************//

void Database::update(string table_Name, string where, string set){

}

[/EndCode]


Related Solutions

C++ using vectors. in the following code, if a user adds duplicate names the votes should...
C++ using vectors. in the following code, if a user adds duplicate names the votes should be added to only one of the names: example display "Enter candidate name: " input john display "Enter candidate vote:" input 10 display "Enter candidate name: " input john display "Enter candidate vote:" input 10 so the output has to be john with 20 votes. #include<iostream> #include<iterator> #include<string> #include<algorithm> #include<array> #include<ctime> #include <vector> #include<bits/stdc++.h> using namespace std; int max_element(const vector<int>&stuff) { int max_index =0;...
All Code should be written in C: 1. Write a C program which prompts the user...
All Code should be written in C: 1. Write a C program which prompts the user to enter two integer values. Your program should then print out all numbers between 1 and 1000 that are divisible by both of those numbers. 2. Modify your program from question 1 such that the first 1000 numbers that are divisible by both numbers are printed out, instead of numbers up to 1000. 3. Using dynamic memory, allocate memory for an array of 100...
Design and implement a C++ program that performs the following steps:Ask the user to enter a...
Design and implement a C++ program that performs the following steps:Ask the user to enter a positive integer number N; Your program may need to prompt the user to enter many times until it reads in a positive number;Let user to enter N (obtained in the previous step) floating point numbers, and count how many positive ones there are in the sequence and sum up these positive numbers; (Hint: negative numbers or 0 are ignored).Display result.You can and should use...
Implement a program in C++ that does the following: Ask the user and read at least...
Implement a program in C++ that does the following: Ask the user and read at least 10 numbers as input from the keyboard and stores them in a an array Displays the array of numbers on the screen (as is, before sorting) Sorts those numbers in the array using Selection Sort Algorithm Displays the array of numbers on the screen (AFTER sorting)
Write a C++ program performing the rot13 cipher, The code should perform like this: The user...
Write a C++ program performing the rot13 cipher, The code should perform like this: The user should be able to input any letter or words, or even sentences where once they have inputted the particular word, each letter goes 13 letters ahead, so an 'A' becomes an 'N', a 'C' becomes 'P', and so on. If rot13 cipher is tested a second time, the original plantext should be restored: 'P' becomes 'C', 'N' becomes 'A'. The 13 letters go in...
Implement a class called DoublyLinkedList. In the main function, instantiate the DoublyLinkedList class and make sure that there is a user loop and a menu so that the user can access all the list operators.
C++  Implement a class called DoublyLinkedList. In the main function, instantiate the DoublyLinkedList class and make sure that there is a user loop and a menu so that the user can access all the list operators. You should implement the following operators, and any others that you may deem best. DestroyList InitializeList GetFirst InsertFirst, InsertLast, Insert DeleteFirst, DeleteLast, Delete IsEmpty Length Print, ReversePrint
Selection Sort Programmatically Implement in C++ the necessary program that does the following: Asks the user...
Selection Sort Programmatically Implement in C++ the necessary program that does the following: Asks the user and gets at least 5 whole numbers as user input from the keyboard and stores them in an array Displays the numbers from the array on the screen Sorts the numbers in the array using SELECTION SORT Algorithm Displays the sorted numbers on the screen from the array Save your code file as "yourLastname_Firstname_SelectionSort.cpp" and submit your .cpp file. NOTE: This assignment needs only...
Bubble Sort Programmatically Implement in C++ the necessary program that does the following: Asks the user...
Bubble Sort Programmatically Implement in C++ the necessary program that does the following: Asks the user and gets at least 5 whole numbers as user input from the keyboard and stores them in an array Displays the numbers from the array on the screen Sorts the numbers in the array using BUBBLE SORT Algorithm Displays the sorted numbers on the screen from the array Save your code file as "yourLastname_Firstname_BubbleSort.cpp" and submit your .cpp file. NOTE: This assignment needs only...
Assemby language - MIPS Your assembly should implement the C code directly – i.e.,do not ’optimize’...
Assemby language - MIPS Your assembly should implement the C code directly – i.e.,do not ’optimize’ the C code to change the order of operations or reduce computations. Write MIPS assembly code implementing the following C/C++ statement: y = 13 - 11*x; One way of doing the multiply without a multiply instruction is by using many add instructions (x+x+...+x). For this problem you should do it with fewer additions. Hint: We know how to express any integer as a sum...
implement a Message Authentication Code program in either C/C++ or Python. See the following steps. 1....
implement a Message Authentication Code program in either C/C++ or Python. See the following steps. 1. Accept a message as keyboard input to your program. 2. Accept a secret key for the sender/recipient as keyboard input to your program. 3. Your hash function H() is simply the checksum. To compute the checksum, you add all the characters of the string in ASCII codes. For example, the checksum of a string "TAMUC" would be 84 + 65 + 77 + 85...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT