CSc 4710/6710, Database Systems
Spring 2008
Homework 5 (Due: 31 March, 2008 - Monday)

  1. Consider the following relational "category" table definition and sample data from the project:
    drop table category cascade constraints;
    create table category (
      cname varchar2(120),
      primary key cname
    );
    insert into category values ('Books:Biology');
    insert into category values ('Books:Computers');
    insert into category values ('Books:Economics');
    insert into category values ('Books:Fiction');
    insert into category values ('Computers:Apple:Desktops');
    insert into category values ('Computers:Apple:Laptops');
    insert into category values ('Computers:PCs:Desktops');
    insert into category values ('Computers:PCs:Laptops');
    insert into category values ('Computers:Storage:Hard Drives');
    insert into category values ('Computers:Storage:Flash Drives');
    insert into category values ('DVDs:Action');
    insert into category values ('DVDs:Comedy');
    insert into category values ('Music:Blues');
    insert into category values ('Music:Jazz');
    insert into category values ('Music:World');
    insert into category values ('Video Games:Systems:XBox 360');
    insert into category values ('Video Games:Systems:Wii');
    insert into category values ('Video Games:Systems:Playstation');
    insert into category values ('Video Games:Systems:Nintendo DS');
    insert into category values ('Video Games:Games:XBox 360');
    insert into category values ('Video Games:Games:Wii');
    insert into category values ('Video Games:Games:Playstation');
    insert into category values ('Video Games:Games:Nintendo DS');
    
    Write a Java program that will extract the individual category/sub-category from the "category" table and insert the hierarchy into the following table:
    drop table hcategory cascade constraints;
    create table hcategory (
      supercat varchar2(120),
      subcat   varchar2(120),
      primary key (supercat,subcat)
    );
    
    For example, the category "Video Games:Games:Nintendo DS" in the category table will result in two rows: ('Video Games','Games') and ('Games','Nintendo DS') in the hcategory table. You should create the hcategory table outside of the Java environment.
  2. Write a Java program that will implement the following menu system:
    
    (1) Search by keyword
    (2) List items by top-level category
    (3) Quit
    
    Enter your option: 1
    keyword: jones
    category (all or top): all
    
    Search Results:
    ItemNumber Title         ClosingDate       LatestBid
    ----------------------------------------------------
    1111	   Indiana Jones 12 Dec 2008 17.00     24.00
    ...
    ...
    
    (1) Search by keyword
    (2) List items by category
    (3) Quit
    
    Enter your option: 2
    DVD:Action
    
    Results:
    ItemNumber Title         ClosingDate       LatestBid
    ----------------------------------------------------
    1111       Indiana Jones 12 Dec 2008 17.00     24.00
    ...
    ...
    
    (1) Search by keyword
    (2) List items by category
    (3) Quit
    
    Enter your option: 3
    

Page Maintained by raj@cs.gsu.edu