1. Homepage
  2. Coding
  3. CS460 Introduction to Database Systems - Problem Set 3 - Implement portions of a simple relational database management system

CS460 Introduction to Database Systems - Problem Set 3 - Implement portions of a simple relational database management system

Chat with a Specialist
BUCS460Introduction to Database SystemsDBMSSQLJavaMarshall

Problem Set 3

Preliminaries

In your work on this assignment, make sure to abide by the collaboration policies of the course. Assignment Writing Service

If you have questions, please come to office hours, post them on Piazza, or email cs460-staff@cs.bu.edu. Assignment Writing Service

Make sure to submit your work on Gradescope, following the procedures found at the end of Part I and Part II. Assignment Writing Service


Part I

45 points total Assignment Writing Service

Creating the necessary folder

Create a subfolder called ps3 within your cs460 folder, and put all of the files for this assignment in that folder. Assignment Writing Service

Creating the necessary file

This part of the assignment will all be completed in a single PDF file. To create it, you should do the following: Assignment Writing Service

  1. Access the template that we have created by clicking on this link and signing into your Google account as needed. Assignment Writing Service

  2. When asked, click on the Make a copy button, which will save a copy of the template file to your Google Drive. Assignment Writing Service

  3. Select File->Rename, and change the name of the file to ps3_partI. Assignment Writing Service

  4. Add your work for the problems from Part I to this file. Assignment Writing Service

  5. Once you have completed all of these problems, choose File->Download->PDF document, and save the PDF file in your ps3 folder. The resulting PDF file (ps3_partI.pdf) is the one that you will submit. See the submission guidelines at the end of Part I. Assignment Writing Service

Problem 1: Properties of schedules

18 points total Assignment Writing Service

Below are two schedules in which actions by three transactions (T1, T2, and T3) are interleaved. Assignment Writing Service

schedule 1: Assignment Writing Service

w1(A); r3(A); w2(C); r2(B); c2; r1(C); c1; w3(B); c3

schedule 2: Assignment Writing Service

r1(C); w2(B); w1(A); w2(C); c2; r3(B); w3(B); c3; r1(B); c1

For each of the above schedules, you should take the following steps: Assignment Writing Service

  1. In your copy of the ps3_partI template (see above), edit the diagram that we have provided for the schedule, making whatever changes are needed to construct the schedule’s precedence graph. Assignment Writing Service

  2. State whether the schedule is conflict serializable. Explain briefly why or why not. In addition, if the schedule is conflict serializable, state one possible equivalent serial schedule. Assignment Writing Service

  3. State whether the schedule is recoverable. Explain briefly why or why not. Assignment Writing Service

  4. State whether the schedule is cascadeless. Explain briefly why or why not. Assignment Writing Service

Problem 2: Two-phase locking

8 points total Assignment Writing Service

Consider these two transactions: Assignment Writing Service

T1: r(A); r(B); r(C); w(C); commit
T2: r(B); r(A); r(C); w(A); commit
  1. The following is the beginning of one possible schedule of these transactions, with appropriate lock instructions added: Assignment Writing Service

           T1 Assignment Writing Service

           T2 Assignment Writing Service

      sl(A); r(A)
      sl(B); r(B)


        ... Assignment Writing Service



      sl(B); r(B)
      sl(A); r(A)
        ... Assignment Writing Service

    Under regular two-phase locking (not strict or rigorous), could T2’s next action be to unlock B? Explain briefly why or why not. Assignment Writing Service

  2. Regardless of your answer to part 1, imagine that T1 actually goes next and completes two more actions: Assignment Writing Service

           T1 Assignment Writing Service

           T2 Assignment Writing Service

      sl(A); r(A)
      sl(B); r(B)


      sl(C); r(C)
        ... Assignment Writing Service



      sl(B); r(B)
      sl(A); r(A)

        ... Assignment Writing Service

    Fill in the table that we have provided in ps3_partI to show one way in which this partial schedule could be successfully completed under strict two-phase locking. There is more than one possible answer to this question. Assignment Writing Service

    Important guidelines: Assignment Writing Service

    • The actions that you add should go below the dotted lines in the table. Make sure to position them so that there is no confusion about the order in which they occur. Assignment Writing Service

    • Make sure to include appropriate lock, unlock and commit actions. You should assume that the DBMS is not using update locks, and that it allows shared locks to be upgraded to exclusive locks. Assignment Writing Service

    • To show that you understand the difference between strict and rigorous locking, at least one of the unlock actions should come before the commit action of the corresponding transaction. Assignment Writing Service

Problems 3 and 4: Coming soon

19 points total Assignment Writing Service

Submitting your work for Part I

Coming soon! Assignment Writing Service


Part II

55 points total Assignment Writing Service

All of Part II is pair-optional, which means that you may complete it with a partner. See the rules for working with a partner on pair-optional problems for details about how this type of collaboration must be structured. Assignment Writing Service

Overview

In this assignment, you will implement portions of a simple relational database management system that supports a subset of the SQL language. We have provided you with two of the three components of the system: Assignment Writing Service

  1. a SQL parser
  2. Berkeley DB, an embedded database system that will serve as the storage engine. More specifically, we will use Berkeley DB Java Edition.

Your job is to implement parts of the “middle layer” of the system, which takes the parsed version of a SQL command and performs the necessary lower-level actions to execute the command. To help you, we have given you a code framework for the middle layer that already provides some of the necessary functionality. Assignment Writing Service

Getting started

You should begin by downloading the necessary files and configuring your work environment. The steps for doing so can be found here. Assignment Writing Service

Please do this ASAP, so that you can be sure that you don’t run into any problems later on. Assignment Writing Service

After configuring everything, you should spend some time familiarizing yourself with the files that we have given you in the dbms folder, and with Berkeley DB. In particular, you should review/read the following resources: Assignment Writing Service

  • the overview of the code framework
  • the API documentation of the code framework
  • the lecture notes on implementing a logical-to-physical mapping (pages 174-186 in the coursepack)

The following additional resources may also be helpful: Assignment Writing Service

Code-reading and design questions

highly recommended Assignment Writing Service

Before you begin coding, we strongly encourage you to answer the questions found here: Assignment Writing Service

code-reading and design questions Assignment Writing Service

General notes

  • In the code that you write, you must limit yourself to the packages that we’ve imported at the top of the starter files. You must not use classes from any other Java package. In addition, you must not use any Java features that were not present in Java 8. Assignment Writing Service

  • As discussed on the separate configuration page, you will need to compile and run the code from the command line in the Terminal window of VS Code. Assignment Writing Service

    Note: The two commands for running the program are almost identical, but in the Windows version there is a semi-colon (;) before the word classes, whereas the macOS version uses a colon (:). Assignment Writing Service

  • You will see one or more warnings when compiling your code (e.g., “Note: Parser.java uses unchecked or unsafe operations.”). These warnings are to be expected and should be ignored. Messages labeled as errors (not warnings) will keep your code from compiling and will need to be addressed. You shouldn’t see any errors when you compile the starter code that we’ve given you. If you do, let us know. Assignment Writing Service

  • After making changes to the code, you will need to recompile it before you can try to re-run it. When you are at the command line of the Terminal, using the up arrow will allow you to access and reenter previously entered commands without needing to re-type them! Assignment Writing Service

  • The code that we’ve given you can be run before you make any changes. It will begin by printing the following prompt: Assignment Writing Service

    Enter command (q to quit):
    

    If you enter a valid SQL command, the program will parse the command and display a summary of some of the command’s components (see the notes on the DEBUG constant below for how to disable this summary). Entering a lower-case q will allow you to quit the program. Assignment Writing Service

  • When you run the program for the first time, it will create a directory called db within your code directory. This is the home directory for the Berkeley DB environment, and it will be used to store the files that BDB creates for your database. If your program crashes for any reason, these files may be corrupted. As a result, we recommend that you remove all files from this directory after a crash. Assignment Writing Service

  • There is a constant named DEBUG that is defined in DBMS.java. When it is set to true (as it is in the files that we have given you), the values of many of the tokens generated by the parser are printed after each SQL command is entered by the user. You may find this information helpful as you implement the various types of commands. You may also wish to add additional debugging code that is only executed when this constant is set to true. To eliminate the debugging messages, set DEBUG to false. Assignment Writing Service

Problem 5: Marshalling column values

20 points Assignment Writing Service

Important Assignment Writing Service

Before you begin coding, make sure that you have completed the tasks listed under the Getting Started section above, and that you have answered the code-reading and design questions mentioned above. Assignment Writing Service

In order to insert rows into a table, your DBMS needs to be able to marshall a collection of column values into a single Berkeley DB key/value pair. In this problem, you will add support for marshalling by implementing the key method of the InsertRow class. Assignment Writing Service

As you saw when completing the code-reading questions, an InsertRow object is used by the execute() method for INSERT commands (the one in the InsertStatement class). That execute() method creates an InsertRow object to represent the row to be inserted, and it calls that object’s marshall() method to prepare the marshalled key/value pair for the row. Assignment Writing Service

We have already implemented some of the other methods of this class for you: Assignment Writing Service

  • an InsertRow constructor that initializes the state of object. It takes two parameters: an already opened Table object for the table to which the row will be added, and an array of type Object containing the values in the row to be inserted. We assume that the values are in the appropriate order – i.e., that element 0 of the array contains a value for the first column in the table, element 1 contains a value for for the second column in the table, etc. We also assume that the values are valid and that they have been adjusted as needed to correspond to the types of the columns.
  • getKeyBuffer() method that returns a RowOutput object for the key portion of the marshalled key/value pair.
  • getValueBuffer() method that returns a RowOutput object for the value portion of the marshalled key/value pair.
  • toString() method that returns a String representation that includes:
    • the current contents of the offsets field, which we recommend that you use when determining the offset values that will appear at the start of the marshalled value
    • the current contents of the key buffer (i.e., the array of bytes that is inside the RowOutput for the key)
    • the current contents of the value buffer (i.e., the array of bytes that is inside the RowOutput for the value). This toString() method should help you when debugging your marshalling code.

You will implement the marshall() method, which should take the column values of the InsertRow object and marshall them into byte arrays for the key/value pair that will eventually be inserted into the B+tree for the table. Assignment Writing Service

Important: marshall() should not interact with Berkeley DB at all. In particular, it should not create any DatabaseEntry objects or attempt to add them to the BDB database. Assignment Writing Service

Rather, marshall() should only do the following: Assignment Writing Service

  1. Determine the correct offset values and store them in the array to which the offsets field in the InsertRow object refers. Assignment Writing Service

  2. Write the appropriate values into the buffers represented by the keyBuffer and valueBuffer fields, each of which refers to a RowOutput object. Assignment Writing Service

See below for more detail about each of these tasks. Assignment Writing Service

Notes: Assignment Writing Service

  • Each key/value pair should have the format that we discussed in the lecture notes on the logical-to-physical mapping. The key portion of the key/value pair should be based on the value of the primary-key column. The value portion should consist of a header of offsets followed by the values of the non-primary-key, non-null columns. Assignment Writing Service

  • The key portion of the key/value pair will be stored in the RowOutput object assigned to the keyBuffer field of the InsertRow object. The value portion will be stored in the RowOutput object assigned to the valueBuffer field. Assignment Writing Service

  • Because RowOutput objects fill their associated byte arrays from left to right, you will need to determine all of the offsets that belong in the header before you begin marshalling the column values themselves. Store these offsets in the array to which the InsertRow object’s offsets field refers. Assignment Writing Service

  • Once all of the offsets have been computed and stored in the offsets array, you can begin the process of writing into the RowOutput objects using the appropriate methods. Assignment Writing Service

  • The InsertRow constructor takes a reference to the corresponding Table object as a parameter, and it stores that reference in a field called table. Your code can obtain any column information that it needs from the Table object and its associated Column objects. Assignment Writing Service

  • The getLength() method in a Column object gives the actual length in bytes of all columns except VARCHARs. In the case of VARCHARs, you should determine the length by invoking the String.length() method on the actual value. Assignment Writing Service

  • Because the column values are stored in an array of type Object, you will need to use type casts in order to treat them as objects of their actual types. For example, to treat values[i] as a String, you would need to do something like (String)values[i]. Consult the Column class for the method you should use to determine the type of a given column. Assignment Writing Service

  • Integer values are stored in the values array as objects of Java’s Integer class, and real values are stored as objects of Java’s Double class. When marshalling these values, you will need to convert them to primitive values of type int and double, and you should use the Integer.intValue() and Double.doubleValue() methods to do so. For example, if you have an Integer object named val, you can convert it to an int by making the method call val.intValue(). Assignment Writing Service

  • The RowOutput methods that you will use for writing the offsets and column values are inherited from the DataOutputStream class, so you should make sure to review the API of that class. Assignment Writing Service

  • When marshalling a String value, you should use the writeBytes() method, not the writeUTF() method. Assignment Writing Service

  • You should assume that all offset values are small enough to be represented by a two-byte integer, and thus you should use the writeShort() method for them. Assignment Writing Service

  • To keep the marshall() method from getting too large, you may want to add one or more private helper methods that can be called to do part of the overall task. Assignment Writing Service

    Important: If you write a helper method that uses one or more of the RowOutput methods, you must include a throws clause in the header of the method like the one we’ve given you for the marshall method: Assignment Writing Service

    public void marshall() throws IOException { Assignment Writing Service

  • Review the TableColumnRowOutput, and DataOutputStream classes as needed. Assignment Writing Service

Testing your marshall() method

You should test your marshall() method thoroughly before proceding to the next problem. Assignment Writing Service

We’ve given you the following tools for doing so: Assignment Writing Service

  • The RowOutput class includes a toString() method that shows the current contents of the underlying byte array. Assignment Writing Service

  • The InsertRow class includes its own toString() method that shows the current values in the InsertRow object’s offsets array and the contents of the byte arrays underlying the RowOutput objects assigned to its keyBuffer and valueBuffer fields. Assignment Writing Service

  • The starter code that we’ve given you in the execute() method of InsertStatement will create the necessary InsertRow object, call your marshall() method, and – if the DEBUG constant in the DBMS class is true – print the InsertRow object so that you can examine the values of its fields. (Note that the row won’t actually be inserted until you complete the execute() method as part of Problem 4, but the existing code is sufficient for testing the marshall() method.) Assignment Writing Service

Given these tools, you can: Assignment Writing Service

  • Compile and run the DBMS program as described above. Assignment Writing Service

  • Create a table using a CREATE TABLE command. The starter code already includes everything needed to carry out this type of command. Assignment Writing Service

  • Enter one or more INSERT commands for the newly created table, and see if the output from printing the InsertRow object looks correct. Assignment Writing Service

For example, let’s say that you enter these two SQL commands: Assignment Writing Service

CREATE TABLE Movie(id CHAR(7) PRIMARY KEY, name VARCHAR(64), runtime INT);
INSERT INTO Movie VALUES ('2294629', 'Frozen', 102);

If your marshall() command is working correctly, you should see the following as part of the output of the debugging print statement: Assignment Writing Service

  • for the offsets field:
    [-2, 8, 14, 18] Assignment Writing Service

    Because there are three columns, there are four offsets. The -2 indicates that the first column (id) is the primary key. The next two offsets (8 and 14) are the offets of the name and runtime column values, and the 18 is the offset of the end of the record. Assignment Writing Service

  • for the key buffer (i.e., the keyBuffer field):
    [50, 50, 57, 52, 54, 50, 57] Assignment Writing Service

    The numbers in this byte array represent the ASCII codes for the characters in the id value '2294629'50 for the character '2'57 for the character '9', etc. Assignment Writing Service

  • for the value buffer (i.e., the valueBuffer field):
    [-1, -2, 0, 8, 0, 14, 0, 18, 70, 114, 111, 122, 101, 110, 0, 0, 0, 102] Assignment Writing Service

    This byte array begins with 8 bytes for the offset table: Assignment Writing Service

    • The first two bytes ([-1, -2]) represent the special -2 offset for the primary-key column. When -2 is represented using a two-byte integer, the individual bytes end up being the 8-bit representations of -1 and -2. Assignment Writing Service

      In general, when you use multiple bytes to store a negative number whose absolute value is relatively small, the rightmost byte will show the negative number itself, and all of the remaining bytes will show -1. For example, if we stored -3 using two bytes, we would see [-1, -3] as its two bytes. If we stored -10 using four bytes, we would see [-1, -1, -1, -10]. Assignment Writing Service

    • The next two bytes ([0, 8]) represent the offset of the name column, which has an offset of 8 bytes because it comes immediately after the offset table, which has a length of 4*2 = 8 bytes. Assignment Writing Service

    • The next two bytes ([0, 14]) represent the offset of the runtime column, which has an offset of 8 + 6 = 14 bytes in this particular row. Assignment Writing Service

    • The next two bytes ([0, 18]) represent the offset of the end of the record, which is 14 + 4 = 18 in this particular row. Assignment Writing Service

    • The next 6 bytes represent the ASCII codes for 'Frozen'70 for 'F'114 for 'r', etc. Assignment Writing Service

    • The final 4 bytes ([0, 0, 0, 102]) represent the 4-byte integer stored for the runtime value of 102. Assignment Writing Service

Note: When you store larger integers, the resulting bytes can be harder to interpret. Here are some examples: Assignment Writing Service

  • If you stored a runtime of 150 in the Movie table that we created above, you would see the bytes [0, 0, 0, -106] for the runtime. This stems from the fact that when only one byte is used to store a signed integer (one that could be negative), it can store any value between -128 and 127. When we store 150 using two or more bytes, the 8 bits in the rightmost byte look like they represent a negative number, because 150 can’t actually be represented using an 8-bit signed integer. Assignment Writing Service

  • If you stored a runtime of 300, you would see the bytes [0, 0, 1, 44] for the runtime. That’s because we need more than 8 bits to store 300 as a binary number. In fact, when we convert 300 to binary, we get a 9-bit number: 100101100. When these 9 bits are stored as part of a 32-bit integer, we get: Assignment Writing Service

    00000000 00000000 00000001 00101100
    

    The bits in the rightmost byte represent the integer 44, and the bits in the byte to its left represent the integer 1. Assignment Writing Service

Try inserting other rows as well, and convince yourself that your marshall() method is working in all cases. For example, does it work correctly when one of the column values is NULL? Assignment Writing Service

Problem 6: Completing INSERT commands

7 points Assignment Writing Service

We have given you the start of the execute() method of the InsertStatement class, which is used to carry out INSERT commands. As mentioned earlier, our provided code uses an InsertRow object to prepare the row for insertion – marshalling it into a key/value pair. You will need to complete the execute() method by writing code that: Assignment Writing Service

Notes: Assignment Writing Service

  • The insertion should fail if there is already a key/value pair with the specified key. You should choose the BDB insertion method that will return a special value when the specified key already exists. Your code should handle this return value by throwing an exception with an appropriate error message. See our CreateStatement code for examples of throwing an exception. Note: The error message will be printed by the code that we’ve provided in the catch block. You just need to create an exception with the appropriate error message and throw the exception. See our sample interaction below for what the error message should look like. Assignment Writing Service

  • If the insertion is successful, your code should print an appropriate message to indicate that fact. See our sample interaction below for what it should look like. Assignment Writing Service

  • Review the Table and InsertRow classes as needed, as well as the Berkeley DB Database class. Assignment Writing Service

Problem 7: Table iterators and unmarshalling

20 points Assignment Writing Service

In order to execute a SELECT command, your DBMS needs to be able to iterate over the rows in one or more tables, and to access the values of the columns in those rows. In this problem, you will complete the implementation of a table iterator that will be able to iterate over all or some of the rows in a single table and access the values of the columns. We can associate a WHERE clause with such an iterator, in which case it will only visit rows that satisfy the WHERE clause. Assignment Writing Service

Each table iterator will be an instance of the provided TableIterator class. We have already implemented most of the methods of this class for you, including: Assignment Writing Service

  • TableIterator constructor that takes an already opened table object and initializes the state needed by the table iterator, including: Assignment Writing Service

    • a cursor for the underlying BDB database
    • two initially empty DatabaseEntry objects called key and value. These DatabaseEntry objects will be used by the cursor methods to retrieve the current key/value pair.

    The constructor also examines the columns mentioned in the SQL statement for which this iterator is needed, and it associates this iterator with those columns; doing so allows the code that evaluated the WHERE clause to use the iterator to obtain the column values that it needs. - a first() method that positions the iterator on the first tuple of the table. - a next() method that advances the iterator to the next tuple specified by the SELECT command. - a getColumn() method that takes an index nand returns a Column object for the nth column in the table associated with the iterator. The leftmost column has an index of 0. - a close() method that closes the cursor associated with the iterator. - a printAll() method that will be called to iterate over all rows in the associated table and print them out. Assignment Writing Service

For this assignment, you should implement the method called getColumnVal() that takes an index n and returns the value of the nth column in the tuple on which the iterator is currently positioned. To do so, it will need to unmarshall the appropriate value from the BDB key/value pair associated with that tuple, and it should use the metadata that you included when you marshalled the tuple to efficiently access the value of the specified column. See the notes below for more detail. Assignment Writing Service

Notes: Assignment Writing Service

  • We have already given you the code needed to handle the two types of exceptions that are mentioned in the comments before the method. Assignment Writing Service

  • You code that you write should assume that the underlying cursor has already been positioned on an appropriate key/value pair. The key can be accessed using the DatabaseEntry object to which the TableIterator‘s key field refers, and the value can be accessed using the DatabaseEntry object to which the TableIterator‘s value field refers. Assignment Writing Service

  • Your code will need to use one or two RowInput objects to unmarshall the value of the specified column. Assignment Writing Service

    For example, to create a RowInput object that is based on the value portion of the current key/value pair, you would do something like the following: Assignment Writing Service

    RowInput valIn = new RowInput(this.value.getData());
    
  • Your getColumnVal() method should not perform unnecessary reads. Rather, it should only read (1) the offset or offsets needed to determine where the column value is located and (when necessary) the length of the column value, and (2) the column value itself. Assignment Writing Service

  • The RowInput class includes two methods for each type of value: Assignment Writing Service

    • one that reads a value at a specified offset from the start of the byte array (e.g., readIntAtOffset() and readDoubleAtOffset()). These methods jump to the specified position in the underlying byte array before performing the read.
    • one that reads a value at the current offset from the start of the byte array (e.g., readNextInt() and readNextDouble()). When the RowInput object is created, the current offset is set to 0. After each read, the current offset is updated to be the offset of the byte that comes immediately after the value that was just read.
  • The RowInput class also includes a toString() method that you may find useful when debugging. It returns a string that includes the contents of the underlying byte array and the current offset within that array. Assignment Writing Service

  • When unmarshalling the key portion of the key-value pair, you can use the getSize() method in its DatabaseEntry object to determine the key’s length in bytes. Assignment Writing Service

  • Review the TableColumn, and RowInput classes as needed, as well as the Berkeley DB DatabaseEntry class. Assignment Writing Service

Problem 8: SELECT * for a single table

8 points Assignment Writing Service

Implement the execute() method of the SelectStatement class, and any necessary helper methods. For this assignment, you will only need to support SELECT * commands involving a single table. Assignment Writing Service

Your method will need to open the table associated with the SELECT command by using the open() method that we have provided for Table objects. (See the start of the execute() method for InsertStatement for an example of this.) The open() method will get the table’s catalog metadata and add it to the Table object, and it will also open the underlying BDB database if it isn’t already open. Assignment Writing Service

Your code should then create a TableIterator for the appropriate table (assigning it to the variable iter that we have given you) and invoke the printAll() method on it. This method, which we have provided in TableIterator, will invoke the appropriate iterator methods to obtain the table’s column values and display them with appropriate formatting. Note that your SELECT-statement code does not need to advance the iterator by calling next()printAll() already does all of the iteration – and all of the other work – for you, using the TableIterator method that you wrote. Assignment Writing Service

Your execute() method should check for currently unsupported SELECT commands: Assignment Writing Service

  • those with more than one table in the FROM clause
  • those with one or more columns specified in the SELECT clause.

If either of those cases holds, you should throw an exception with an appropriate error message. See our sample interaction below for what these messages should look like. Assignment Writing Service

In addition, your method should make sure that there is an existing table with the given name; the open() method of the Table object should make it easy to do so. When there is no existing table with the specified name, you should create and throw an exception with no error message, because code in the open() method will already print the necessary error message. Assignment Writing Service

If there are no errors, your method should finish by printing a message that includes the number of tuples selected. See our sample interaction below for what these messages should look like. Assignment Writing Service

Notes: Assignment Writing Service

  • When creating the TableIterator, make sure that you use the local variable iter that we have declared for you at the top of the method. Doing so will allow you to take advantage of the code that we have given you at the end of the method, which closes the iterator, and thus its underlying cursor. Assignment Writing Service

  • The TableIterator constructor takes a reference to an object of type SQLStatement. You should pass in a reference to the SelectStatement object on which the execute method was invoked, which you can do by using the implicit parameter this. In addition, you should pass in true for the third parameter of the constructor: Assignment Writing Service

    iter = new TableIterator(this, ..., true);
    
  • When you call the printAll() method, you should pass in System.out as the parameter, so that the results will be displayed on the console. (The reason that we make printAll() take a parameter for this is for added flexibility. If we wanted to, we could pass in a parameter that corresponds to a text file, and the results would be written to that file instead of to the console.) Assignment Writing Service

  • Review the TableTableIterator, and SQLStatement classes as needed. Assignment Writing Service

Sample interaction

To give you a sense of what your DBMS’s output should look like, we have provided a sample interaction below. Note: We set the DEBUG constant to false in DBMS.java before we ran these commands. Assignment Writing Service

Enter command (q to quit): CREATE TABLE Course(name VARCHAR(20), enrollment INT);
Created table Course.

Enter command (q to quit): SELECT * FROM Course;
 | name                 | enrollment |
---------------------------------------

Selected 0 tuples.

Enter command (q to quit): DROP TABLE Course;
Dropped table Course.

Enter command (q to quit): SELECT * FROM Course;
Course: no such table

Enter command (q to quit): CREATE TABLE Course(id CHAR(5) PRIMARY KEY, name VARCHAR(20));
Created table Course.

Enter command (q to quit): INSERT INTO Course VALUES ('01000', 'CS 460');
Added 1 row to Course.

Enter command (q to quit): INSERT INTO Course VALUES ('00050', 'Math 123');
Added 1 row to Course.

Enter command (q to quit): INSERT INTO Course VALUES ('02050', NULL);
Added 1 row to Course.

Enter command (q to quit): INSERT INTO Course VALUES ('00050', 'Physics 211');
There is an existing row with the specified primary key.
Could not insert row.

Enter command (q to quit): SELECT * FROM Course;
 | id    | name                 |
----------------------------------
 | 00050 | Math 123             |
 | 01000 | CS 460               |
 | 02050 | null                 |

Selected 3 tuples.

Enter command (q to quit): SELECT name FROM Course;
Specifying column names in the SELECT clause is not supported.

Enter command (q to quit): CREATE TABLE Foo(id CHAR(5) PRIMARY KEY, year INT);
Created table Foo.

Enter command (q to quit): SELECT * FROM Course, Foo;
Specifying multiple table names in the FROM clause is not supported.

Enter command (q to quit): q

Submitting your work for Part II

Coming soon! Assignment Writing Service

联系辅导老师!
私密保护
WeChat 微信
BU代写,CS460代写,Introduction to Database Systems代写,DBMS代写,SQL代写,Java代写,Marshall代写,BU代编,CS460代编,Introduction to Database Systems代编,DBMS代编,SQL代编,Java代编,Marshall代编,BU代考,CS460代考,Introduction to Database Systems代考,DBMS代考,SQL代考,Java代考,Marshall代考,BU代做,CS460代做,Introduction to Database Systems代做,DBMS代做,SQL代做,Java代做,Marshall代做,BUhelp,CS460help,Introduction to Database Systemshelp,DBMShelp,SQLhelp,Javahelp,Marshallhelp,BU作业代写,CS460作业代写,Introduction to Database Systems作业代写,DBMS作业代写,SQL作业代写,Java作业代写,Marshall作业代写,BU编程代写,CS460编程代写,Introduction to Database Systems编程代写,DBMS编程代写,SQL编程代写,Java编程代写,Marshall编程代写,BU作业答案,CS460作业答案,Introduction to Database Systems作业答案,DBMS作业答案,SQL作业答案,Java作业答案,Marshall作业答案,