Chris Pollett >
Students > [Bio] [Intro to jQuery and YUI - PDF] |
Deliverable 4GoalsThe goals of this deliverable are:
Description of the applicationIn 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. Implementationfunction 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); new_attr.set_is_foreign_key(true); db.find_table(src_tbl).add_attribute(new_attr); $('#'+src_tbl+'_tbl .db_attrs').append(new_tbl_div); var rel = new Relationship(src_tbl, dest_tbl, src_fk, dest_temp[2]); db.add_relationship(rel); drawLineBetweenBox(src_fk, dest_tbl_id); } SnapshotsFig 1: Automatic creation of foreign key when user links two tables together Relevant files |