Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

EECS 281: Project 3 - “SillyQL”

Overview

A relational database is the most common means of data storage and retrieval in the modern age. A relational database model stores data into one or more tables, where each table has    columns and rows. The columns represent a value that can be attributed to an entry (such as

color ,  name , or  ID ) and the rows represent individual entries or records (such as  Paoletti ,

my_cat , or  BBB_1695 ). You may find it helpful to think about rows as objects and columns as descriptors for those objects. For instance, the table pictured below has each row corresponding   to a car (a data type), and the columns group a car’s vendors, model, etc. such that this                information can be easily retrieved. Rows in relational databases are also called records or tuples, but in this project we will use the terminology row” for consistency. Rows in Project 3 are not guaranteed to be unique.

However, a database can do much more than simply store information. You must be able to        retrieve specific information in an efficient manner. For relational databases, the structured query language (SQL) is a defined method of retrieving information programmatically. It looks like real English, where a valid command for the above table could be:

which would return a list of models:

Note that the version of SQL used in this project is simplified and modified somewhat from a typical query language.

For this project, you will write a program to emulate a basic relational database with an interface based on a subset of a standard query language. Your executable will be called  silly . You will  gain experience writing code that makes use of multiple interacting data structures. The design  portion of this project is significant; spend time thinking about what data structures you will use and how they will interact.

Learning Goals


Selecting appropriate data structures for a given problem. Now that you know how to use various abstract data types, its important that you are able to evaluate which will be the   optimal for a set of tasks.

Evaluating the runtime and storage tradeoffs for storing and accessing data contained in multiple data structures.

Designing a range of algorithms to handle different situations.

Evaluating different representations of the same data.

Command Line Arguments

silly should accept the following (both optional) command line arguments:

-h , --help

This causes the program to print a helpful message about how to use the program and then immediately exit(0) .

-q , --quiet

This causes the program to run in quiet mode. In quiet mode, your program will run very             similarly to normal, except that it will print only numerical summaries of the rows affected by the command, not any of the actual data. Quiet mode exists so that we may stress test your program without overloading the autograder with too much output. This flag only affects the JOIN and

PRINT commands, and specific instructions for quiet mode output is given for these commands. Otherwise, if there is no mention of quiet mode with respect to a given piece of output, you may assume it is always printed. You can implement this feature last; with a well-built project, adding this functionality should be very simple.

You may find it simpler to check for these flags directly rather than use getopt.

Database Shell

Your program will create a shell that allows users to interact with a single database that is created in memory and destroyed when the program is quit by the user. A shell is a program that             presents a prompt (“% “) to allow a user to enter commands and also view displayed output         while interacting with the system. Since the commands to the shell come from standard input

( cin ) and display to standard output ( cout ), the program will be useable both directly from the keyboard locally and via redirected input ( < ) and output ( > ) locally and on the autograder.

Each command is specified by a keyword followed by a required space character ( ) and then the command-specific arguments where applicable. Like other database languages, some commands use additional required words that help make them more readable. These words can be both       guaranteed to appear and completely ignored. For example, the command to delete rows from a table uses the keyword  DELETE and adds  FROM , for improved readability/pronuciation. So to       delete the rows from  table1 where the entries in column  name equal  John , the correct              command would be:

Spec Example contains an example program illustrating the use of all the commands.

Database Commands

These commands affect the structure of the database and the running of the command shell.  They include the creation and removal of tables, but do not deal with any actual data (items of type  string ,  double ,  int or  bool ).

CREATE

Add a new table to the database:

CREATE Syntax

1 CREATE <tablename> <N> <coltype1> <coltype2> ... <coltypeN> <colname1> <colname2> .

Creates a new table with  N columns (where  N > 0). Each column contains data of type

 and is accessed with the name   . Table names and column names are      guaranteed to be space-free. No two columns in the same table will have the same name (you do not need to check). Valid data types for  coltype are  {double, int, bool, string} . This    table is initially empty.

CREATE Output

Print the following on a single line followed by a newline:

CREATE: Possible errors

1. A table named   already exists in the database

See Errors and Error Messages for acceptable output formats.

Given the following as input:

The output should be:

QUIT


Exit the program and delete all data in the database.

QUIT Syntax

1 QUIT


Cleans up all internal data (i.e. no memory leaks) and exits the program. Note that the program must exit with a return 0 from main() .

QUIT Output

Print a goodbye message, followed by a newline.

1 Thanks for being silly!


QUIT: Possible errors

None, except for lacking a QUIT command. Every interactive session or redirected input file should end with a QUIT command.

# (comment)