Answered step by step
Verified Expert Solution
Question
1 Approved Answer
package heapdb.query; import java.util.ArrayList; import heapdb.ITable; import heapdb.Schema; import heapdb.Table; import heapdb.Tuple; / * * * A simple select query of the form: * select
package heapdb.query;
import java.util.ArrayList;
import heapdb.ITable;
import heapdb.Schema;
import heapdb.Table;
import heapdb.Tuple;
A simple select query of the form:
select column, column, from table where condition
@author Glenn
public class SelectQuery
private Condition cond;
private String colNames; a value of null means return all columns of the table
A query that contains both a where condition and a projection of columns
@param colNames are the columns to return
@param cond is the where clause
public SelectQueryString colNames, Condition cond
this.colNames colNames;
this.cond cond;
A query that contains both a where condition. All columns
of the Tuples are returned.
@param cond is the where clause
public SelectQueryCondition cond
thisnull cond;
public static Table naturalJoinITable table ITable table
Schema resultSchema tablegetSchemanaturaljointablegetSchema;
Table result new TableresultSchema;
ArrayList joinColumns new ArrayList;
TODO find the list of join column of the tables
for Tuple t: table
for Tuple t: table
TODO if t matches all join columns of t
TODO then insert the join of t and t into
the result table
return result;
public ITable evalITable table
Schema s;
if there is a projection operation, make the new schema
if colNamesnull s table.getSchema;
else s table.getSchemaprojectcolNames;
Table result new Tables;
for Tuple t: table
TODO
if condevalt
result.inserttprojects;
return result;
@Override
public String toString
String projcolumns;
if colNames null
projcolumns String.join colNames;
else
projcolumns ;
return "select projcolumns where cond;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started