In Memory Relational Database Testing
Test Programs
Write Java programs, Query1.java, Query2.java, and Query6.java, which code queries 1, 2 and 6 respectively, fromRelational Algebra Queries on the Company Database.
The files required to load the "company" database are available at
You should create a folder, called company, in your Eclipse project root folder and import these files in this folder. Then, you should be able to use the method from Week 2 to load this database into memory. The code to load the data is shown below:
import java.util.*; public class Query1 { public static void main(String args[]) { Database db = new Database(); db.initializeDatabase(args[0]); Relation r1 = db.getRelation("EMPLOYEE"); Relation r2 = db.getRelation("DEPARTMENT"); // Now you can code the query as a sequence of method calls to the operators that were implemented. ... ... ... } }You should get the following output when you run these 3 programs:
[raj@tinman w7]$ java Query1 company ANSWER(FNAME:VARCHAR,LNAME:VARCHAR,ADDRESS:VARCHAR) Number of tuples: 4 Franklin:Wong:638 Voss, Houston, TX: John:Smith:731 Fondren, Houston, TX: Ramesh:Narayan:971 Fire Oak, Humble, TX: Joyce:English:5631 Rice, Houston, TX:
[raj@tinman w7]$ java Query2 company ANSWER(PNUMBER:INTEGER,DNUM:INTEGER,LNAME:VARCHAR,ADDRESS:VARCHAR,BDATE:VARCHAR) Number of tuples: 2 10:4:Wallace:291 Berry, Bellaire, TX:20-JUN-31: 30:4:Wallace:291 Berry, Bellaire, TX:20-JUN-31:
[raj@tinman w7]$ java Query6 company ANSWER(LNAME:VARCHAR,FNAME:VARCHAR) Number of tuples: 34 Borg:James: Zelaya:Alicia: Narayan:Ramesh: English:Joyce: Jabbar:Ahmad: James:Jared: James:John: Jones:Jon: Mark:Justin: Knight:Brad: Wallis:Evan: Zell:Josh: Vile:Andy: Brand:Tom: Vos:Jenny: Carter:Chris: Grace:Kim: Chase:Jeff: Snedden:Sam: Ball:Nandita: Bender:Bob: Jarvis:Jill: King:Kate: Leslie:Lyle: King:Billie: Kramer:Jon: King:Ray: Small:Gerald: Head:Arnold: Pataki:Helga: Drew:Naveen: Reedy:Carl: Hall:Sammy: Bacher:Red: