From: lingutln Date: Wed, 24 Apr 2013 22:41:31 +0000 (+0000) Subject: File reorganizatio and initial checkins for data import scripts X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=38d259d8a5190c8828abdb076bfc6b24cab675d4;p=old-jaiswallab-svn%2F.git File reorganizatio and initial checkins for data import scripts svn path=/; revision=468 --- diff --git a/image_annotation_db/ia_upload/annotation_data_importer.pl b/image_annotation_db/ia_upload/annotation_data_importer.pl new file mode 100644 index 0000000..debbbef --- /dev/null +++ b/image_annotation_db/ia_upload/annotation_data_importer.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w + +=head1 NAME + + Image Annotation Data Importer + +=head1 VERSION + + 0.1 + +=head1 DESCRIPTION + + Read the data from the tab de;imited files present in the image_data directory present adjacent to this file + Add more description + +=head1 USAGE + + annotation_data_importer.pl + +=cut + +# general + +use strict; +use English; +use DBI; + +# configurations + +use constant IMAGE_DATA_DIR => "image_data"; + +sub establish_db_connection +{ + return DBI->connect('DBI:mysql:image_annotation;host=floret.cgrb.oregonstate.edu', 'lingutln', 'nikhil_iadb', + { RaiseError => 1 } + ); +} + +sub insert_curator_data(my $dbh, my @image_data_fields) +{ + my($curator_first, $curator_last) = split(/ /, $image_data_fields[6], 2); + my $curator_email = $image_data_fields[7]; + my $curator_affiliation = $image_data_fields[8]; + + $dbh->do('INSERT INTO curator (firstname, lastname, primary_email, alternate_email, affiliation) VALUES(?, ?, ?, ?, ?)', undef, $curator_first, $curator_last , $curator_email ,'', $curator_affiliation); + +} + +sub insert_record_into_database +{ + my $dbh = establish_db_connection; + + my @image_data_fields = split(/\t/); + + insert_curator_data($dbh, @image_data_fields); + + + +} + +sub import_image_data +{ + + print "Opening each image data(*.tsv) file and reading data...\n\n"; + + foreach (glob(IMAGE_DATA_DIR."/*.tsv")) + { + + my $content = do { + local $/ = undef; + open (my $file, "<", $_) or die("could not open $_: $!"); + <$file>; + }; + + chomp; + + my @image_data_records = split(/\n/, $content); + + splice @image_data_records, 0, 1; + + foreach (@image_data_records) + { + insert_record_into_database($_); + } + + close $_ or die("Could not close '$_': $OS_ERROR"); + + } +} + +# --------------------------------------------------------------------------- + # main +# --------------------------------------------------------------------------- + +import_image_data; +exit; + +# --------------------------------------------------------------------------- +# end +# --------------------------------------------------------------------------- diff --git a/image_annotation_db/ia_upload/annotation_data_importer.pl~ b/image_annotation_db/ia_upload/annotation_data_importer.pl~ new file mode 100644 index 0000000..debbbef --- /dev/null +++ b/image_annotation_db/ia_upload/annotation_data_importer.pl~ @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w + +=head1 NAME + + Image Annotation Data Importer + +=head1 VERSION + + 0.1 + +=head1 DESCRIPTION + + Read the data from the tab de;imited files present in the image_data directory present adjacent to this file + Add more description + +=head1 USAGE + + annotation_data_importer.pl + +=cut + +# general + +use strict; +use English; +use DBI; + +# configurations + +use constant IMAGE_DATA_DIR => "image_data"; + +sub establish_db_connection +{ + return DBI->connect('DBI:mysql:image_annotation;host=floret.cgrb.oregonstate.edu', 'lingutln', 'nikhil_iadb', + { RaiseError => 1 } + ); +} + +sub insert_curator_data(my $dbh, my @image_data_fields) +{ + my($curator_first, $curator_last) = split(/ /, $image_data_fields[6], 2); + my $curator_email = $image_data_fields[7]; + my $curator_affiliation = $image_data_fields[8]; + + $dbh->do('INSERT INTO curator (firstname, lastname, primary_email, alternate_email, affiliation) VALUES(?, ?, ?, ?, ?)', undef, $curator_first, $curator_last , $curator_email ,'', $curator_affiliation); + +} + +sub insert_record_into_database +{ + my $dbh = establish_db_connection; + + my @image_data_fields = split(/\t/); + + insert_curator_data($dbh, @image_data_fields); + + + +} + +sub import_image_data +{ + + print "Opening each image data(*.tsv) file and reading data...\n\n"; + + foreach (glob(IMAGE_DATA_DIR."/*.tsv")) + { + + my $content = do { + local $/ = undef; + open (my $file, "<", $_) or die("could not open $_: $!"); + <$file>; + }; + + chomp; + + my @image_data_records = split(/\n/, $content); + + splice @image_data_records, 0, 1; + + foreach (@image_data_records) + { + insert_record_into_database($_); + } + + close $_ or die("Could not close '$_': $OS_ERROR"); + + } +} + +# --------------------------------------------------------------------------- + # main +# --------------------------------------------------------------------------- + +import_image_data; +exit; + +# --------------------------------------------------------------------------- +# end +# --------------------------------------------------------------------------- diff --git a/image_annotation_db/ia_upload/balaji_prototype/contact_process.php b/image_annotation_db/ia_upload/balaji_prototype/contact_process.php new file mode 100755 index 0000000..64d6287 --- /dev/null +++ b/image_annotation_db/ia_upload/balaji_prototype/contact_process.php @@ -0,0 +1,104 @@ + 0 && $row[0] == '')) + return -1; + return $row[0]; + } + + function get_image_source_version_id($image_source_id,$source_version){ + $query = "select image_source_version_id from image_source_version where image_source_id='$image_source_id' and source_version='$source_version'"; + $row = getRowFromDB($query,"image source version id"); + if(count($row) == 0 || (count($row) > 0 && $row[0] == '')) + return -1; + return $row[0]; + } + + function save_image_source_version_information($image_source_id,$contact){ + $source_version = $contact['source_version']; + $publication_id = $contact['publication_id']; + $contribution_date = $contact['contribution_date']; + $mysqldate = date( 'Y-m-d H:i:s', $contribution_date ); + $contribution_date = strtotime( $mysqldate ); + + $id_from_db = get_image_source_version_id($image_source_id,$source_version); + if($id_from_db == -1){ + $query = "INSERT INTO image_source_version(image_source_id,source_version,contribution_date,publication_id) VALUES('$image_source_id','$source_version','$contribution_date','$publication_id')"; + $rsrcResult = mysql_query($query); + if (!$rsrcResult) { + echo "DB Error while trying to add new image source version information\n"; + echo 'MySQL Error: ' . mysql_error(); + exit(); + } + $id_from_db = get_image_source_version_id($image_source_id,$source_version); + } + return $id_from_db; + } + + $file = $_FILES['file']['tmp_name']; + $file_handle = fopen($file, "r"); + $contact = array(); + while (!feof($file_handle)) { + $line = fgets($file_handle); + $s = explode("\t",$line); + if($s[0] != "") + $contact[$s[0]] = $s[1]; + } + fclose($file_handle); + + if(count($contact) < 4 || $contact['source_name'] == '' || $contact['contributor_name'] == '' || $contact['contact_email'] == '' || $contact['contribution_date'] == ''){ + echo "Required information is missing. "; + } + else{ + $image_source_id = save_image_source_information($contact); + $image_source_version_id = save_image_source_version_information($image_source_id,$contact); + + if($image_source_id != -1 && $image_source_version_id != -1){ + echo "information saved successfully
"; + echo "Click here to upload annotated image data file"; + } + else{ + echo "Couldn't save information"; + exit(); + } + } + +?> diff --git a/image_annotation_db/ia_upload/balaji_prototype/data.html b/image_annotation_db/ia_upload/balaji_prototype/data.html new file mode 100755 index 0000000..8972814 --- /dev/null +++ b/image_annotation_db/ia_upload/balaji_prototype/data.html @@ -0,0 +1,18 @@ + + +Tool for uploading image annotation information + + +

Tool for uploading image annotation information

+

Step 2

+

Please upload the image annotation information file below

+


+
+ + +
+ +
+ + + diff --git a/image_annotation_db/ia_upload/balaji_prototype/index.html b/image_annotation_db/ia_upload/balaji_prototype/index.html new file mode 100755 index 0000000..1f3ded2 --- /dev/null +++ b/image_annotation_db/ia_upload/balaji_prototype/index.html @@ -0,0 +1,18 @@ + + +Tool for uploading image annotation information + + +

Tool for uploading image annotation information

+

Step 1

+

Please upload the contact information file below

+


+
+ + +
+ +
+ + + diff --git a/image_annotation_db/ia_upload/contact_process.php b/image_annotation_db/ia_upload/contact_process.php deleted file mode 100755 index 64d6287..0000000 --- a/image_annotation_db/ia_upload/contact_process.php +++ /dev/null @@ -1,104 +0,0 @@ - 0 && $row[0] == '')) - return -1; - return $row[0]; - } - - function get_image_source_version_id($image_source_id,$source_version){ - $query = "select image_source_version_id from image_source_version where image_source_id='$image_source_id' and source_version='$source_version'"; - $row = getRowFromDB($query,"image source version id"); - if(count($row) == 0 || (count($row) > 0 && $row[0] == '')) - return -1; - return $row[0]; - } - - function save_image_source_version_information($image_source_id,$contact){ - $source_version = $contact['source_version']; - $publication_id = $contact['publication_id']; - $contribution_date = $contact['contribution_date']; - $mysqldate = date( 'Y-m-d H:i:s', $contribution_date ); - $contribution_date = strtotime( $mysqldate ); - - $id_from_db = get_image_source_version_id($image_source_id,$source_version); - if($id_from_db == -1){ - $query = "INSERT INTO image_source_version(image_source_id,source_version,contribution_date,publication_id) VALUES('$image_source_id','$source_version','$contribution_date','$publication_id')"; - $rsrcResult = mysql_query($query); - if (!$rsrcResult) { - echo "DB Error while trying to add new image source version information\n"; - echo 'MySQL Error: ' . mysql_error(); - exit(); - } - $id_from_db = get_image_source_version_id($image_source_id,$source_version); - } - return $id_from_db; - } - - $file = $_FILES['file']['tmp_name']; - $file_handle = fopen($file, "r"); - $contact = array(); - while (!feof($file_handle)) { - $line = fgets($file_handle); - $s = explode("\t",$line); - if($s[0] != "") - $contact[$s[0]] = $s[1]; - } - fclose($file_handle); - - if(count($contact) < 4 || $contact['source_name'] == '' || $contact['contributor_name'] == '' || $contact['contact_email'] == '' || $contact['contribution_date'] == ''){ - echo "Required information is missing. "; - } - else{ - $image_source_id = save_image_source_information($contact); - $image_source_version_id = save_image_source_version_information($image_source_id,$contact); - - if($image_source_id != -1 && $image_source_version_id != -1){ - echo "information saved successfully
"; - echo "Click here to upload annotated image data file"; - } - else{ - echo "Couldn't save information"; - exit(); - } - } - -?> diff --git a/image_annotation_db/ia_upload/data.html b/image_annotation_db/ia_upload/data.html deleted file mode 100755 index 8972814..0000000 --- a/image_annotation_db/ia_upload/data.html +++ /dev/null @@ -1,18 +0,0 @@ - - -Tool for uploading image annotation information - - -

Tool for uploading image annotation information

-

Step 2

-

Please upload the image annotation information file below

-


-
- - -
- -
- - - diff --git a/image_annotation_db/ia_upload/image_data/IADB_img_data_DWS_NYBG_20130404.tab - Sheet1.tsv b/image_annotation_db/ia_upload/image_data/IADB_img_data_DWS_NYBG_20130404.tab - Sheet1.tsv new file mode 100644 index 0000000..9a7ce3e --- /dev/null +++ b/image_annotation_db/ia_upload/image_data/IADB_img_data_DWS_NYBG_20130404.tab - Sheet1.tsv @@ -0,0 +1,17 @@ +filename import_location keywords ontology_term_ids species species_id curator_name curator_email curator_affiliation collection_location geo_coords collection_date ip_comment doi source_db comments +Saurauia xs Ovary.jpg / locule|ovule|pericarp|septum PO:0025266|PO:0020003|PO:0009084|PO:0025262 Saurauia sp Dennis Stevenson dws@nybg.org NYBG COLOMBIA: Boyaca: Villa de Lleva, Iguaque National Park 2500-2800 M 20070429 PlantSystematics:DOL27827 +Helleborus_argutifolius_Carpels.jpg / carpel|style PO:0009030|PO:0009074 Helleborus argutifolius Dennis Stevenson dws@nybg.org NYBG AUSTRALIA: South Australia: Botanic Gardens of Adelaide Accession G880864 20110810 PlantSystematics:DOL40035 +Yucca_schidigera_flower.jpg / anther|filament|flower|ovary|petal|sepal|stigma PO:0009066|PO:0009067|PO:0009046|PO:0009072|PO:0009032|PO:0009031|PO:0009073 Yucca schidigera Lawrence M. Kelly lkelly@nybg.org NYBG USA: California:: San Diego Co. Near Miramar NAS 20040320 PlantSystematics:DOL11866 +Gunnera_tinctoria Prickle.jpg / prickle PO:0025169 Gunnera tinctoria Dennis Stevenson dws@nybg.org NYBG DENMARK: University of Copenhagen, Botanical Garden E6139 C001 A 20080813 PlantSystematics:DOL33711 + Acacia cornigera Stipules as Spines.jpg / stipule|stipule spine PO:0020041|PO:0025174 Acacia cornigera Lawrence M. Kelly lkelly@nybg.org NYBG COSTA RICA: Guanacaste: Palo Verde 2003 PlantSystematics:DOL4821 +Bougainvillea_spectabilis Thorn.jpg / thorn PO:0025172 Bougainvillea spectabilis Dennis Stevenson dws@nybg.org NYBG CHINA: Shenzhen, Fairylake Botanical Garden 20111025 +Parmentiera_cerifera Style & Stigma.jpg / stigma|style PO:0009073|PO:0009074 Parmentiera cerifera Dennis Stevenson dws@nybg.org NYBG USA: Florida:: Dade Co. Montgomery Botanical Center  20070404 PlantSystematics:DOL27681 +Leucojum_aestivum Flower.jpg / collective tepal structure|free tepal|plant ovary|stamen|tepal PO:0025021|PO:0025136PO:0009072|PO:0009029|PO:0009033 Leucojum aestivum Dennis Stevenson dws@nybg.org NYBG USA: NY:: Tompkins Co. Mins Garden, Cornell University 20050428 PlantSystematics:DOL12340|DOL12342 +Ticodendron incognitum.jpg / shoot node|petiole|shoot internode|stipule PO:0005004|PO:0020038|PO:0005005|PO:0020041| Ticodendron incognitum Lawrence M. Kelly lkelly@nybg.org NYBG COSTA RICA: Alajuela:: San Ramon Estacion Biologica Alberto M. Brenes 2003 PlantSystematics:DOL4844 +Agave sebastiana Labelled.jpg / locule|ovule|septum PO:0025266|PO:0020003|PO:0025262 Agave sebastiana Dennis Stevenson dws@nybg.org NYBG USA: California:: Santa Barbara Co. Santa Barbara Botanic Garden 20061208 PlantSystematics:DOL26528 +Acacia mangium Phyllode.JPG / inflorescence|phyllode leaf PO:0009049|PO:0025335 Acacia mangium Dennis Stevenson dws@nybg.org NYBG VIETNAM: Vinh Phuc Province: Me Linh District, Me Linh Station of the Institute of Ecology and Biological Resources, Vietnamese Academy of Science and Technology 21 23.309 N 105 42.837 E 20051210 PlantSystematics:DOL17750 +Acacia sp Phyllode.JPG / axillary inflorescence bud|phyllode leaf PO:0004711|PO:0025335 Acacia sp Dennis Stevenson dws@nybg.org NYBG AUSTRALIA: Western Australia: Kings Park, Perth 20110805 PlantSystematics:DOL39936 +EucalyptusKingsmillii6.JPG / calyptra corolla PO:0025330 Eucalyptus kingsmillii Dennis Stevenson dws@nybg.org NYBG AUSTRALIA: Western Australia: Kings Park, Perth 20110805 PlantSystematics:DOL39933 +EucalyptusKingsmillii2.JPG / calyptra corolla PO:0025330 Eucalyptus kingsmillii Dennis Stevenson dws@nybg.org NYBG AUSTRALIA: Western Australia: Kings Park, Perth 20110805 PlantSystematics:DOL39929 +GymnocalyciumMarsoneri1.JPG / areole bud|spine leaf PO:0025353|PO:0025173 Gymnocalycium marsoneri Dennis Stevenson dws@nybg.org NYBG USA: Arizona:: Maricopa Co. Desert Botanical Garden, Phoenix 20070114 PlantSystematics:DOL26949 +Anchomanes giganteus.JPG / prickle PO:0025169 Anchomanes giganteus Dennis Stevenson dws@nybg.org NYBG GERMANY: Botanical Garden, University of Bonn. Accession No. 02608 20060924 \ No newline at end of file diff --git a/image_annotation_db/ia_upload/index.html b/image_annotation_db/ia_upload/index.html deleted file mode 100755 index 1f3ded2..0000000 --- a/image_annotation_db/ia_upload/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - -Tool for uploading image annotation information - - -

Tool for uploading image annotation information

-

Step 1

-

Please upload the contact information file below

-


-
- - -
- -
- - - diff --git a/image_annotation_db/image_annotation.mwb b/image_annotation_db/image_annotation.mwb deleted file mode 100644 index 8ed60e1..0000000 Binary files a/image_annotation_db/image_annotation.mwb and /dev/null differ diff --git a/image_annotation_db/image_annotation.png b/image_annotation_db/image_annotation.png deleted file mode 100644 index 99d8db7..0000000 Binary files a/image_annotation_db/image_annotation.png and /dev/null differ diff --git a/image_annotation_db/image_annotation.sql b/image_annotation_db/image_annotation.sql deleted file mode 100644 index 34826e7..0000000 --- a/image_annotation_db/image_annotation.sql +++ /dev/null @@ -1,168 +0,0 @@ -SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; -SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; -SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; - -CREATE SCHEMA IF NOT EXISTS `image_annotation` DEFAULT CHARACTER SET latin1 ; -USE `image_annotation` ; - --- ----------------------------------------------------- --- Table `image_annotation`.`Species_map` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`Species_map` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`Species_map` ( - `ubio_id` INT(11) NOT NULL , - `po_species_id` INT(11) NOT NULL , - PRIMARY KEY (`ubio_id`) , - INDEX `fk_Species_map_1` (`po_species_id` ASC) , - CONSTRAINT `fk_Species_map_1` - FOREIGN KEY (`po_species_id` ) - REFERENCES `po_beta`.`species` (`id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`Annotated_term_type` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`Annotated_term_type` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_term_type` ( - `annotated_term_type_id` INT(11) NOT NULL , - `annotated_term_type` VARCHAR(45) NULL DEFAULT NULL , - PRIMARY KEY (`annotated_term_type_id`) ) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`Annotated_term` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`Annotated_term` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_term` ( - `annotated_term_id` INT(11) NOT NULL , - `annotated_term` VARCHAR(45) NULL DEFAULT NULL , - `annotated_term_type_id` INT(11) NULL DEFAULT NULL , - `po_term_id` INT(11) NULL DEFAULT NULL , - PRIMARY KEY (`annotated_term_id`) , - INDEX `fk_Annotated Term_1` (`annotated_term_type_id` ASC) , - INDEX `fk_Annotated_term_2` (`po_term_id` ASC) , - CONSTRAINT `fk_Annotated Term_1` - FOREIGN KEY (`annotated_term_type_id` ) - REFERENCES `image_annotation`.`Annotated_term_type` (`annotated_term_type_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Annotated_term_2` - FOREIGN KEY (`po_term_id` ) - REFERENCES `po_beta`.`term` (`id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`Annotated_image` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`Annotated_image` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_image` ( - `annotated_image_id` INT(11) NOT NULL , - `image_path` VARCHAR(255) NULL DEFAULT NULL , - `curator` VARCHAR(45) NULL DEFAULT NULL , - `comments` VARCHAR(45) NULL DEFAULT NULL , - `annotated_term_id` INT(11) NULL DEFAULT NULL , - `ubio_id` INT(11) NULL DEFAULT NULL , - `ubio_name` VARCHAR(45) NULL DEFAULT NULL , - `species_name` VARCHAR(45) NULL DEFAULT NULL , - PRIMARY KEY (`annotated_image_id`) , - INDEX `fk_Annotated_image_1` (`ubio_id` ASC) , - INDEX `fk_Annotated_image_3` (`annotated_term_id` ASC) , - CONSTRAINT `fk_Annotated_image_1` - FOREIGN KEY (`ubio_id` ) - REFERENCES `image_annotation`.`Species_map` (`ubio_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Annotated_image_3` - FOREIGN KEY (`annotated_term_id` ) - REFERENCES `image_annotation`.`Annotated_term` (`annotated_term_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`Annotated_keyword` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`Annotated_keyword` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_keyword` ( - `annotated_keyword_id` INT(11) NOT NULL , - `annotated_keyword` VARCHAR(45) NULL DEFAULT NULL , - PRIMARY KEY (`annotated_keyword_id`) ) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`Annotated_keywordlist` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`Annotated_keywordlist` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_keywordlist` ( - `annotated_image_id` INT(11) NOT NULL , - `annotated_keyword_id` INT(11) NOT NULL , - PRIMARY KEY (`annotated_image_id`, `annotated_keyword_id`) , - INDEX `fk_Annotated_keywordlist_1` (`annotated_image_id` ASC) , - INDEX `fk_Annotated_keywordlist_2` (`annotated_keyword_id` ASC) , - CONSTRAINT `fk_Annotated_keywordlist_1` - FOREIGN KEY (`annotated_image_id` ) - REFERENCES `image_annotation`.`Annotated_image` (`annotated_image_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Annotated_keywordlist_2` - FOREIGN KEY (`annotated_keyword_id` ) - REFERENCES `image_annotation`.`Annotated_keyword` (`annotated_keyword_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`Segment` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`Segment` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`Segment` ( - `segment_id` INT(11) NOT NULL , - `color` VARCHAR(45) NULL DEFAULT NULL , - `annotated_image_id` INT(11) NULL DEFAULT NULL , - `byte_mask` BLOB NULL DEFAULT NULL , - `coordinates` LINESTRING NULL DEFAULT NULL , - `annotated_term_id` INT(11) NULL DEFAULT NULL , - PRIMARY KEY (`segment_id`) , - INDEX `fk_Segment_2` (`annotated_term_id` ASC) , - INDEX `fk_Segment_1` (`annotated_image_id` ASC) , - CONSTRAINT `fk_Segment_1` - FOREIGN KEY (`annotated_image_id` ) - REFERENCES `image_annotation`.`Annotated_image` (`annotated_image_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Segment_2` - FOREIGN KEY (`annotated_term_id` ) - REFERENCES `image_annotation`.`Annotated_term` (`annotated_term_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - - -SET SQL_MODE=@OLD_SQL_MODE; -SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; -SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/image_annotation_db/image_annotation_v1.11.mwb b/image_annotation_db/image_annotation_v1.11.mwb deleted file mode 100644 index a292898..0000000 Binary files a/image_annotation_db/image_annotation_v1.11.mwb and /dev/null differ diff --git a/image_annotation_db/image_annotation_v1.11.png b/image_annotation_db/image_annotation_v1.11.png deleted file mode 100644 index a9eeaec..0000000 Binary files a/image_annotation_db/image_annotation_v1.11.png and /dev/null differ diff --git a/image_annotation_db/image_annotation_v1_11_load.sql b/image_annotation_db/image_annotation_v1_11_load.sql deleted file mode 100644 index e984040..0000000 --- a/image_annotation_db/image_annotation_v1_11_load.sql +++ /dev/null @@ -1,220 +0,0 @@ -SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; -SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; -SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; - -CREATE SCHEMA IF NOT EXISTS `image_annotation` DEFAULT CHARACTER SET latin1 ; -USE `image_annotation` ; - --- ----------------------------------------------------- --- Table `image_annotation`.`image_source` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`image_source` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`image_source` ( - `image_source_id` INT NOT NULL AUTO_INCREMENT , - `source_name` VARCHAR(80) NULL , - `url` VARCHAR(255) NULL , - `contact_email` VARCHAR(80) NULL , - `contributor_name` VARCHAR(80) NULL , - PRIMARY KEY (`image_source_id`) ) -ENGINE = InnoDB; - - --- ----------------------------------------------------- --- Table `image_annotation`.`image_source_version` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`image_source_version` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`image_source_version` ( - `image_source_version_id` INT NOT NULL , - `image_source_id` INT NULL , - `source_version` VARCHAR(45) NULL , - `contribution_date` DATE NULL , - `publication_id` VARCHAR(45) NULL , - PRIMARY KEY (`image_source_version_id`) , - INDEX `fk_Image_source_version_1` (`image_source_id` ASC) , - CONSTRAINT `fk_Image_source_version_1` - FOREIGN KEY (`image_source_id` ) - REFERENCES `image_annotation`.`image_source` (`image_source_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB; - - --- ----------------------------------------------------- --- Table `image_annotation`.`curator` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`curator` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`curator` ( - `curator_id` INT NOT NULL AUTO_INCREMENT , - `firstname` VARCHAR(80) NULL , - `lastname` VARCHAR(80) NULL , - `primary_email` VARCHAR(80) NULL , - `alternate_email` VARCHAR(80) NULL , - `affiliation` VARCHAR(80) NULL , - PRIMARY KEY (`curator_id`) ) -ENGINE = InnoDB; - - --- ----------------------------------------------------- --- Table `image_annotation`.`taxon` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`taxon` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`taxon` ( - `taxon_id` INT NOT NULL AUTO_INCREMENT , - `species_id` VARCHAR(45) NULL , - `species_name` VARCHAR(80) NULL , - `common_name` VARCHAR(80) NULL , - `genus` VARCHAR(80) NULL , - `subspecies` VARCHAR(80) NULL , - PRIMARY KEY (`taxon_id`) ) -ENGINE = InnoDB; - - --- ----------------------------------------------------- --- Table `image_annotation`.`annotated_image` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`annotated_image` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`annotated_image` ( - `annotated_image_id` INT NOT NULL AUTO_INCREMENT , - `curator_id` INT NULL DEFAULT NULL , - `image_source_version_id` INT NULL , - `taxon_id` INT NULL DEFAULT NULL , - `annotated_image` LONGBLOB NULL , - `image_path` VARCHAR(255) NULL DEFAULT NULL , - `annotated_image_type` VARCHAR(45) NULL , - `timestamp` DATE NULL , - `software_name` VARCHAR(45) NULL , - `software_version` VARCHAR(32) NULL , - `comments` VARCHAR(255) NULL , - `ip_comment` VARCHAR(255) NULL , - `collection_location` VARCHAR(255) NULL , - `collection_date` DATE NULL , - `source_db_name` VARCHAR(45) NULL , - `source_db_id` INT(11) NULL , - `doi` VARCHAR(45) NULL , - PRIMARY KEY (`annotated_image_id`) , - INDEX `fk_Annotated_image_1` (`image_source_version_id` ASC) , - INDEX `fk_Annotated_image_3` (`curator_id` ASC) , - INDEX `fk_Annotated_image_2` (`taxon_id` ASC) , - CONSTRAINT `fk_Annotated_image_1` - FOREIGN KEY (`image_source_version_id` ) - REFERENCES `image_annotation`.`image_source_version` (`image_source_version_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Annotated_image_3` - FOREIGN KEY (`curator_id` ) - REFERENCES `image_annotation`.`curator` (`curator_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Annotated_image_2` - FOREIGN KEY (`taxon_id` ) - REFERENCES `image_annotation`.`taxon` (`taxon_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`annotated_term` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`annotated_term` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`annotated_term` ( - `annotated_term_id` INT NOT NULL AUTO_INCREMENT , - `keyword` VARCHAR(80) NULL DEFAULT NULL , - `ontology_term_id` VARCHAR(80) NULL DEFAULT NULL , - `ontology_term_name` VARCHAR(80) NULL DEFAULT NULL , - `isKeyword` BIT NULL , - PRIMARY KEY (`annotated_term_id`) ) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`segment` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`segment` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`segment` ( - `segment_id` INT NOT NULL AUTO_INCREMENT , - `annotated_image_id` INT NULL , - `color` VARCHAR(40) NULL DEFAULT NULL , - `byte_mask` LONGBLOB NULL DEFAULT NULL , - `coordinates` LINESTRING NULL DEFAULT NULL , - PRIMARY KEY (`segment_id`) , - INDEX `fk_Segment_1` (`annotated_image_id` ASC) , - CONSTRAINT `fk_Segment_1` - FOREIGN KEY (`annotated_image_id` ) - REFERENCES `image_annotation`.`annotated_image` (`annotated_image_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB -DEFAULT CHARACTER SET = latin1; - - --- ----------------------------------------------------- --- Table `image_annotation`.`annotated_term_image` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`annotated_term_image` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`annotated_term_image` ( - `annotated_term_image_id` INT NOT NULL AUTO_INCREMENT , - `annotated_term_id` INT NULL , - `annotated_image_id` INT NULL , - PRIMARY KEY (`annotated_term_image_id`) , - INDEX `fk_Annotated_term_image_2` (`annotated_term_id` ASC) , - INDEX `fk_Annotated_term_image_1` (`annotated_image_id` ASC) , - CONSTRAINT `fk_Annotated_term_image_2` - FOREIGN KEY (`annotated_term_id` ) - REFERENCES `image_annotation`.`annotated_term` (`annotated_term_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Annotated_term_image_1` - FOREIGN KEY (`annotated_image_id` ) - REFERENCES `image_annotation`.`annotated_image` (`annotated_image_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB; - - --- ----------------------------------------------------- --- Table `image_annotation`.`annotated_term_segment` --- ----------------------------------------------------- -DROP TABLE IF EXISTS `image_annotation`.`annotated_term_segment` ; - -CREATE TABLE IF NOT EXISTS `image_annotation`.`annotated_term_segment` ( - `annotated_term_segment_id` INT NOT NULL AUTO_INCREMENT , - `segment_id` INT NULL , - `annotated_term_id` INT NULL , - `trait_term_id` INT NULL , - PRIMARY KEY (`annotated_term_segment_id`) , - INDEX `fk_Annotated_term_segment_1` (`annotated_term_id` ASC) , - INDEX `fk_Annotated_term_segment_2` (`segment_id` ASC) , - INDEX `fk_Annotated_term_segment_3` (`trait_term_id` ASC) , - CONSTRAINT `fk_Annotated_term_segment_1` - FOREIGN KEY (`annotated_term_id` ) - REFERENCES `image_annotation`.`annotated_term` (`annotated_term_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Annotated_term_segment_2` - FOREIGN KEY (`segment_id` ) - REFERENCES `image_annotation`.`segment` (`segment_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `fk_Annotated_term_segment_3` - FOREIGN KEY (`trait_term_id` ) - REFERENCES `image_annotation`.`annotated_term` (`annotated_term_id` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION) -ENGINE = InnoDB; - - - -SET SQL_MODE=@OLD_SQL_MODE; -SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; -SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/image_annotation_db/sql/image_annotation.mwb b/image_annotation_db/sql/image_annotation.mwb new file mode 100644 index 0000000..8ed60e1 Binary files /dev/null and b/image_annotation_db/sql/image_annotation.mwb differ diff --git a/image_annotation_db/sql/image_annotation.png b/image_annotation_db/sql/image_annotation.png new file mode 100644 index 0000000..99d8db7 Binary files /dev/null and b/image_annotation_db/sql/image_annotation.png differ diff --git a/image_annotation_db/sql/image_annotation.sql b/image_annotation_db/sql/image_annotation.sql new file mode 100644 index 0000000..34826e7 --- /dev/null +++ b/image_annotation_db/sql/image_annotation.sql @@ -0,0 +1,168 @@ +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; + +CREATE SCHEMA IF NOT EXISTS `image_annotation` DEFAULT CHARACTER SET latin1 ; +USE `image_annotation` ; + +-- ----------------------------------------------------- +-- Table `image_annotation`.`Species_map` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`Species_map` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`Species_map` ( + `ubio_id` INT(11) NOT NULL , + `po_species_id` INT(11) NOT NULL , + PRIMARY KEY (`ubio_id`) , + INDEX `fk_Species_map_1` (`po_species_id` ASC) , + CONSTRAINT `fk_Species_map_1` + FOREIGN KEY (`po_species_id` ) + REFERENCES `po_beta`.`species` (`id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`Annotated_term_type` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`Annotated_term_type` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_term_type` ( + `annotated_term_type_id` INT(11) NOT NULL , + `annotated_term_type` VARCHAR(45) NULL DEFAULT NULL , + PRIMARY KEY (`annotated_term_type_id`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`Annotated_term` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`Annotated_term` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_term` ( + `annotated_term_id` INT(11) NOT NULL , + `annotated_term` VARCHAR(45) NULL DEFAULT NULL , + `annotated_term_type_id` INT(11) NULL DEFAULT NULL , + `po_term_id` INT(11) NULL DEFAULT NULL , + PRIMARY KEY (`annotated_term_id`) , + INDEX `fk_Annotated Term_1` (`annotated_term_type_id` ASC) , + INDEX `fk_Annotated_term_2` (`po_term_id` ASC) , + CONSTRAINT `fk_Annotated Term_1` + FOREIGN KEY (`annotated_term_type_id` ) + REFERENCES `image_annotation`.`Annotated_term_type` (`annotated_term_type_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Annotated_term_2` + FOREIGN KEY (`po_term_id` ) + REFERENCES `po_beta`.`term` (`id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`Annotated_image` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`Annotated_image` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_image` ( + `annotated_image_id` INT(11) NOT NULL , + `image_path` VARCHAR(255) NULL DEFAULT NULL , + `curator` VARCHAR(45) NULL DEFAULT NULL , + `comments` VARCHAR(45) NULL DEFAULT NULL , + `annotated_term_id` INT(11) NULL DEFAULT NULL , + `ubio_id` INT(11) NULL DEFAULT NULL , + `ubio_name` VARCHAR(45) NULL DEFAULT NULL , + `species_name` VARCHAR(45) NULL DEFAULT NULL , + PRIMARY KEY (`annotated_image_id`) , + INDEX `fk_Annotated_image_1` (`ubio_id` ASC) , + INDEX `fk_Annotated_image_3` (`annotated_term_id` ASC) , + CONSTRAINT `fk_Annotated_image_1` + FOREIGN KEY (`ubio_id` ) + REFERENCES `image_annotation`.`Species_map` (`ubio_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Annotated_image_3` + FOREIGN KEY (`annotated_term_id` ) + REFERENCES `image_annotation`.`Annotated_term` (`annotated_term_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`Annotated_keyword` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`Annotated_keyword` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_keyword` ( + `annotated_keyword_id` INT(11) NOT NULL , + `annotated_keyword` VARCHAR(45) NULL DEFAULT NULL , + PRIMARY KEY (`annotated_keyword_id`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`Annotated_keywordlist` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`Annotated_keywordlist` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`Annotated_keywordlist` ( + `annotated_image_id` INT(11) NOT NULL , + `annotated_keyword_id` INT(11) NOT NULL , + PRIMARY KEY (`annotated_image_id`, `annotated_keyword_id`) , + INDEX `fk_Annotated_keywordlist_1` (`annotated_image_id` ASC) , + INDEX `fk_Annotated_keywordlist_2` (`annotated_keyword_id` ASC) , + CONSTRAINT `fk_Annotated_keywordlist_1` + FOREIGN KEY (`annotated_image_id` ) + REFERENCES `image_annotation`.`Annotated_image` (`annotated_image_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Annotated_keywordlist_2` + FOREIGN KEY (`annotated_keyword_id` ) + REFERENCES `image_annotation`.`Annotated_keyword` (`annotated_keyword_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`Segment` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`Segment` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`Segment` ( + `segment_id` INT(11) NOT NULL , + `color` VARCHAR(45) NULL DEFAULT NULL , + `annotated_image_id` INT(11) NULL DEFAULT NULL , + `byte_mask` BLOB NULL DEFAULT NULL , + `coordinates` LINESTRING NULL DEFAULT NULL , + `annotated_term_id` INT(11) NULL DEFAULT NULL , + PRIMARY KEY (`segment_id`) , + INDEX `fk_Segment_2` (`annotated_term_id` ASC) , + INDEX `fk_Segment_1` (`annotated_image_id` ASC) , + CONSTRAINT `fk_Segment_1` + FOREIGN KEY (`annotated_image_id` ) + REFERENCES `image_annotation`.`Annotated_image` (`annotated_image_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Segment_2` + FOREIGN KEY (`annotated_term_id` ) + REFERENCES `image_annotation`.`Annotated_term` (`annotated_term_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + + +SET SQL_MODE=@OLD_SQL_MODE; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/image_annotation_db/sql/image_annotation_v1.11.mwb b/image_annotation_db/sql/image_annotation_v1.11.mwb new file mode 100644 index 0000000..a292898 Binary files /dev/null and b/image_annotation_db/sql/image_annotation_v1.11.mwb differ diff --git a/image_annotation_db/sql/image_annotation_v1.11.png b/image_annotation_db/sql/image_annotation_v1.11.png new file mode 100644 index 0000000..a9eeaec Binary files /dev/null and b/image_annotation_db/sql/image_annotation_v1.11.png differ diff --git a/image_annotation_db/sql/image_annotation_v1_11_load.sql b/image_annotation_db/sql/image_annotation_v1_11_load.sql new file mode 100644 index 0000000..e984040 --- /dev/null +++ b/image_annotation_db/sql/image_annotation_v1_11_load.sql @@ -0,0 +1,220 @@ +SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; + +CREATE SCHEMA IF NOT EXISTS `image_annotation` DEFAULT CHARACTER SET latin1 ; +USE `image_annotation` ; + +-- ----------------------------------------------------- +-- Table `image_annotation`.`image_source` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`image_source` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`image_source` ( + `image_source_id` INT NOT NULL AUTO_INCREMENT , + `source_name` VARCHAR(80) NULL , + `url` VARCHAR(255) NULL , + `contact_email` VARCHAR(80) NULL , + `contributor_name` VARCHAR(80) NULL , + PRIMARY KEY (`image_source_id`) ) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`image_source_version` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`image_source_version` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`image_source_version` ( + `image_source_version_id` INT NOT NULL , + `image_source_id` INT NULL , + `source_version` VARCHAR(45) NULL , + `contribution_date` DATE NULL , + `publication_id` VARCHAR(45) NULL , + PRIMARY KEY (`image_source_version_id`) , + INDEX `fk_Image_source_version_1` (`image_source_id` ASC) , + CONSTRAINT `fk_Image_source_version_1` + FOREIGN KEY (`image_source_id` ) + REFERENCES `image_annotation`.`image_source` (`image_source_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`curator` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`curator` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`curator` ( + `curator_id` INT NOT NULL AUTO_INCREMENT , + `firstname` VARCHAR(80) NULL , + `lastname` VARCHAR(80) NULL , + `primary_email` VARCHAR(80) NULL , + `alternate_email` VARCHAR(80) NULL , + `affiliation` VARCHAR(80) NULL , + PRIMARY KEY (`curator_id`) ) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`taxon` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`taxon` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`taxon` ( + `taxon_id` INT NOT NULL AUTO_INCREMENT , + `species_id` VARCHAR(45) NULL , + `species_name` VARCHAR(80) NULL , + `common_name` VARCHAR(80) NULL , + `genus` VARCHAR(80) NULL , + `subspecies` VARCHAR(80) NULL , + PRIMARY KEY (`taxon_id`) ) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`annotated_image` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`annotated_image` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`annotated_image` ( + `annotated_image_id` INT NOT NULL AUTO_INCREMENT , + `curator_id` INT NULL DEFAULT NULL , + `image_source_version_id` INT NULL , + `taxon_id` INT NULL DEFAULT NULL , + `annotated_image` LONGBLOB NULL , + `image_path` VARCHAR(255) NULL DEFAULT NULL , + `annotated_image_type` VARCHAR(45) NULL , + `timestamp` DATE NULL , + `software_name` VARCHAR(45) NULL , + `software_version` VARCHAR(32) NULL , + `comments` VARCHAR(255) NULL , + `ip_comment` VARCHAR(255) NULL , + `collection_location` VARCHAR(255) NULL , + `collection_date` DATE NULL , + `source_db_name` VARCHAR(45) NULL , + `source_db_id` INT(11) NULL , + `doi` VARCHAR(45) NULL , + PRIMARY KEY (`annotated_image_id`) , + INDEX `fk_Annotated_image_1` (`image_source_version_id` ASC) , + INDEX `fk_Annotated_image_3` (`curator_id` ASC) , + INDEX `fk_Annotated_image_2` (`taxon_id` ASC) , + CONSTRAINT `fk_Annotated_image_1` + FOREIGN KEY (`image_source_version_id` ) + REFERENCES `image_annotation`.`image_source_version` (`image_source_version_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Annotated_image_3` + FOREIGN KEY (`curator_id` ) + REFERENCES `image_annotation`.`curator` (`curator_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Annotated_image_2` + FOREIGN KEY (`taxon_id` ) + REFERENCES `image_annotation`.`taxon` (`taxon_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`annotated_term` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`annotated_term` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`annotated_term` ( + `annotated_term_id` INT NOT NULL AUTO_INCREMENT , + `keyword` VARCHAR(80) NULL DEFAULT NULL , + `ontology_term_id` VARCHAR(80) NULL DEFAULT NULL , + `ontology_term_name` VARCHAR(80) NULL DEFAULT NULL , + `isKeyword` BIT NULL , + PRIMARY KEY (`annotated_term_id`) ) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`segment` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`segment` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`segment` ( + `segment_id` INT NOT NULL AUTO_INCREMENT , + `annotated_image_id` INT NULL , + `color` VARCHAR(40) NULL DEFAULT NULL , + `byte_mask` LONGBLOB NULL DEFAULT NULL , + `coordinates` LINESTRING NULL DEFAULT NULL , + PRIMARY KEY (`segment_id`) , + INDEX `fk_Segment_1` (`annotated_image_id` ASC) , + CONSTRAINT `fk_Segment_1` + FOREIGN KEY (`annotated_image_id` ) + REFERENCES `image_annotation`.`annotated_image` (`annotated_image_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`annotated_term_image` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`annotated_term_image` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`annotated_term_image` ( + `annotated_term_image_id` INT NOT NULL AUTO_INCREMENT , + `annotated_term_id` INT NULL , + `annotated_image_id` INT NULL , + PRIMARY KEY (`annotated_term_image_id`) , + INDEX `fk_Annotated_term_image_2` (`annotated_term_id` ASC) , + INDEX `fk_Annotated_term_image_1` (`annotated_image_id` ASC) , + CONSTRAINT `fk_Annotated_term_image_2` + FOREIGN KEY (`annotated_term_id` ) + REFERENCES `image_annotation`.`annotated_term` (`annotated_term_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Annotated_term_image_1` + FOREIGN KEY (`annotated_image_id` ) + REFERENCES `image_annotation`.`annotated_image` (`annotated_image_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `image_annotation`.`annotated_term_segment` +-- ----------------------------------------------------- +DROP TABLE IF EXISTS `image_annotation`.`annotated_term_segment` ; + +CREATE TABLE IF NOT EXISTS `image_annotation`.`annotated_term_segment` ( + `annotated_term_segment_id` INT NOT NULL AUTO_INCREMENT , + `segment_id` INT NULL , + `annotated_term_id` INT NULL , + `trait_term_id` INT NULL , + PRIMARY KEY (`annotated_term_segment_id`) , + INDEX `fk_Annotated_term_segment_1` (`annotated_term_id` ASC) , + INDEX `fk_Annotated_term_segment_2` (`segment_id` ASC) , + INDEX `fk_Annotated_term_segment_3` (`trait_term_id` ASC) , + CONSTRAINT `fk_Annotated_term_segment_1` + FOREIGN KEY (`annotated_term_id` ) + REFERENCES `image_annotation`.`annotated_term` (`annotated_term_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Annotated_term_segment_2` + FOREIGN KEY (`segment_id` ) + REFERENCES `image_annotation`.`segment` (`segment_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT `fk_Annotated_term_segment_3` + FOREIGN KEY (`trait_term_id` ) + REFERENCES `image_annotation`.`annotated_term` (`annotated_term_id` ) + ON DELETE NO ACTION + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + + +SET SQL_MODE=@OLD_SQL_MODE; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;