Consider the following "tilde table" that could be represented

Added on - 16 Sep 2019

  • 2


  • 434


  • 243


  • 0


Trusted by +2 million users,
assist thousands of students everyday
Showing pages 1 to 1 of 2 pages
Consider the following "tilde table" that could be represented by the file cars.txt for persistenceMAKE~MODEL~TYPE~PRICEToyota~Camry~Sedan~18000Toyota~Tacoma~Truck~19000Ford~Mustang~Sport~21000Chevrolet~Corvette~Sport~48000Ford~F150~Truck~25000Toyota~Highlander~SUV~35000Since this is just for education purposes we will allow tilde tables to have the following attributes andlimitations:-at most 12 columns-first row represents column names-all columns are strings (unless you want to define some types)-column values and column names are limited to 16 charactersWrite a java class named Algebra that will eventually have static methods representing the relationalalgebra and one additional method which displays the contents of a tilde table. All methods except forthe display method return a string indicating success or an error message and for every successfuloperation a new tilde table is produced on disk. For now implement the method to show the table, theproject operation, the restrict operation, and one other of your choice from this list:JOIN (assumes natural inner join), UNION, MINUS, INTERSECT, DIVIDESo the main body of a driver program might look like this://restrict the cars table to toyotas producing a table named toyotasAlgebra.Restrict("cars","MAKE='Toyota'","toyotas");//project just three columns from the toyotas table producing a table named answerAlgebra.Project("Toyotas","Make,Model,Price","answer");//display the contents of the answer tableAlgebra.Display("answer");output would be:MAKE MODEL PRICE---------------- ---------------- ----------------Toyota Camry 18000Toyota Tacoma 19000Toyota Highlander 35000Make your program generalizable. That is, it should work with any tilde table. Since the assumption foroption 1 is that tables may not fit into memory you are not allowed to load all the rows into an array orother collection. You can of course load a list of column names or something small like that intomemory. If you can think of a way to clean up the temporary results tables that would be good. In
You’re reading a preview
Preview Documents

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document