top of page

CS 4700/6700 Project P1 relational algebra (RA) Java Assignment Solution

Updated: Aug 16, 2023

In this project each student will implement a Java program to process relational algebra (RA) queries. Combined with file editing for updating data, this can lead to a simplified database system.

Input relations/tables are given in csv format; their file names have the form RN.txt, where RN is a relation’s name. The first line of each such file lists the attribute names of the relation, separated by commas. Attributes are assumed to have either strings or integers or decimal numbers as domains for this project; in Java, students can check what domain a given attribute has from the attribute values in the input files.

Relational algebra queries are given in an input file (named as RAqueries.txt), having one query per line. Your Java program reads RAqueries.txt and then processes the queries contained in it. Your program should also write to an output file named as “RAoutput.csv”; it contains one RA query on one line, followed by the output produced for that query. The file should contain all the queries your program can process. Your Java program will know what relation names are of interest after reading RAqueries.txt.

Inside RAqueries.txt, relational algebra operators PROJECT, SELECT, INTERSECT, and JOIN are typed as these four-letter strings: PROJ, SELE, INTE, JOIN; Natural JOIN is typed as *, UNION is typed as U, CROSS PRODUCT is typed as X, and DIFFERENCE is typed as -; subscripts are used to represent conditions for selections and to represent list of attributes for projections; the comma “,” is used to represent “AND” and the word “OR” represents itself. For simplicity, in this project we do not work with the logical “OR” and “NOT” and, among the joins, we only work with the natural join.

csv stands for “comma separated values”. An example csv line with 5 values is:

2, abc, 4, xyzu, 9.3

An example RAqueries.txt contains the following six lines/queries:

SELE_{Payment > 80} (Play)

PROJ_{ANO, MNO} (Play)



(PROJ_{ANO} (SELE_{Payment > 80} (Play))) - (PROJ_{ANO} (SELE_{Payment < 70} (Play)))

(PROJ_{ANO} (SELE_{Payment > 80} (Play))) U (PROJ_{ANO} (SELE_{ Payment < 70} (Play)))

Students can use any Java structures/classes as long as they are not intended for directly supporting RA operators. Students cannot use database-like systems in their Java programs. You should implement Java functions for various RA operators and then use the functions to process the queries. Your java program can assume that all the input files are in the folder where your submitted program is to be run.

Students write a report to describe the following:

1. A line indicating that can be copy/pasted to Run the Program on Windows or Unix; type How to Run the Program as section title of this line.

2. A list of Implemented Operators/Queries (using Line 1, … Line 6 to refer to the six queries and type PROJECT, SELECT, INTERSECT, JOIN, *, UNION, Difference, CROSS PRODUCT, Composition to indicate the list of operators were implemented). Composition (of operators) is considered as an operator.

3. Two Screenshots showing results produced by the implemented Java program when processing line 3 and line 4 in RAqueries.txt. If your program can not process these two lines, then provide screenshots of two other lines that your program can process; note that this will lead to lower marks. Demonstration on how to make screenshots is given in a file in the project folder on pilot.

4. Output Produced by the implemented Java program answering the RA queries in RAqueries.txt (these are the contents of RAoutput.csv).

Use the bolden words in each item given above as a section title in the report to facilitate reading/marking. Use the string “Section: ” before the section titles. Sections not included in your report in this manner will be treated as “not submitted”.

Submit the following on pilot: Your report (a file) and your java program (a compressed file using zip etc). Your submitted files should not contain the example files provided by the instructor.

Marking will focus on what was done, correctness, and readability.

Different input files may be used when marking your program.

For Best Price and Plagiarism Free with 100% accuracy Java Solution with Report:

Please WhatsApp at:

+91 - 995 314 1035 Solution Includes: Plagiarism and AI report with 100% Accuracy.

117 views0 comments


bottom of page