Relational Algebra Operations in Java: Project, Restrict, Join

Verified

Added on  2019/09/16

|2
|434
|514
Project
AI Summary
This Java project focuses on implementing relational algebra operations. The assignment requires the creation of a Java class named Algebra that includes methods for Project, Restrict, and Join operations, along with a display method. The project involves working with "tilde tables", where data is stored in a specific format. The implementation must handle data persistence, and the solution avoids loading the entire table into memory to accommodate potentially large datasets. The Restrict operation is limited to a single condition, and the comparators are limited to specific operators. The project emphasizes the generalizability of the code, ensuring it works with any tilde table. Successful operations produce new tables on disk. The core functionality includes the ability to filter, select specific columns, and join tables based on a simplified set of rules. The solution demonstrates how to manipulate and query data stored in a tabular format, simulating database operations within a Java environment.
Document Page
Consider the following "tilde table" that could be represented by the file cars.txt for persistence
MAKE~MODEL~TYPE~PRICE
Toyota~Camry~Sedan~18000
Toyota~Tacoma~Truck~19000
Ford~Mustang~Sport~21000
Chevrolet~Corvette~Sport~48000
Ford~F150~Truck~25000
Toyota~Highlander~SUV~35000
Since this is just for education purposes we will allow tilde tables to have the following attributes and
limitations:
-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 characters
Write a java class named Algebra that will eventually have static methods representing the relational
algebra and one additional method which displays the contents of a tilde table. All methods except for
the display method return a string indicating success or an error message and for every successful
operation a new tilde table is produced on disk. For now implement the method to show the table, the
project operation, the restrict operation, and one other of your choice from this list:
JOIN (assumes natural inner join), UNION, MINUS, INTERSECT, DIVIDE
So the main body of a driver program might look like this:
//restrict the cars table to toyotas producing a table named toyotas
Algebra.Restrict("cars","MAKE='Toyota'","toyotas");
//project just three columns from the toyotas table producing a table named answer
Algebra.Project("Toyotas","Make,Model,Price","answer");
//display the contents of the answer table
Algebra.Display("answer");
output would be:
MAKE MODEL PRICE
---------------- ---------------- ----------------
Toyota Camry 18000
Toyota Tacoma 19000
Toyota Highlander 35000
Make your program generalizable. That is, it should work with any tilde table. Since the assumption for
option 1 is that tables may not fit into memory you are not allowed to load all the rows into an array or
other collection. You can of course load a list of column names or something small like that into
memory. If you can think of a way to clean up the temporary results tables that would be good. In
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
order to limit the grammar your restriction condition can be limited to a single condition (so no ANDs
and ORs) and your comparitors can be limited to these six: =, >, <, >=, <=, !=
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]