Chris Pollett > Students >

    ( Print View )


    [Project Blog]

    [CS 297 Proposal]

    [Intro to jQuery and YUI - PDF]

    [Deliverable 1]

    [Deliverable 2]

    [Deliverable 3]

    [Deliverable 4]

    [CS 297 Report - PDF]

    [CS 298 Proposal]

    [CS 298 Report - PDF]

    [CS 298 Slides - PPT]

    [CS 298 Codes - Zip]


Deliverable 4


The goals of this deliverable are:
  • To combine the "create new table" and "QBE" features into one application
  • Automatic creation of foreign key when linking two tables

Description of the application

In this application, user will still be able to create new tables, edit tables, delete tables, create SQL queries by using QBE, and import to SQL queries. The only new addition to the application is the ability of the application to automatically create a foreign key when user links two tables together. This feature will be helpful since not all users are familiar with foreign key concepts.


    function auto_create_fk(src_tbl_id, dest_tbl_id)
      var source_temp = src_tbl_id.split("_");
      var dest_temp = dest_tbl_id.split("_");
      var src_tbl = source_temp[0];
      var dest_tbl = dest_temp[0];
      var src_fk = source_temp[0]+'_'+dest_temp[0]+'_fk';
      new_tbl_div = '<div class="db_attrs_row db_attrs_row_fk" id="'+src_fk+'">'+src_fk+'</div>';
      var new_attr = new Attribute(src_fk, 'BIGINT', '','',0);
      $('#'+src_tbl+'_tbl .db_attrs').append(new_tbl_div);
      var rel = new Relationship(src_tbl, dest_tbl, src_fk, dest_temp[2]);
      drawLineBetweenBox(src_fk, dest_tbl_id);


Automatic creation of foreign key
Fig 1: Automatic creation of foreign key when user links two tables together

Relevant files