--- /dev/null
+#!/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
+# ---------------------------------------------------------------------------
--- /dev/null
+#!/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
+# ---------------------------------------------------------------------------
--- /dev/null
+<?php
+
+ //db config values
+ $dbHost = "localhost";
+ $dbUser = "root";
+ $dbPwd = "root";
+ $connection = mysql_connect($dbHost,$dbUser,$dbPwd);
+ mysql_select_db("image_annotation");
+
+ function getRowFromDB($query,$value){
+ $rsrcResult = mysql_query($query);
+ if (!$rsrcResult) {
+ echo "DB Error while trying to retrieve $value\n MySQL Error: ".mysql_error();
+ exit();
+ }
+ $row = mysql_fetch_row($rsrcResult);
+ return $row;
+ }
+
+ function save_image_source_information($contact){
+ $contributor_name = $contact['contributor_name'];
+ $source_name = $contact['source_name'];
+ $url = $contact['url'];
+ $contact_email = $contact['contact_email'];
+ $id_from_db = get_image_source_id($contributor_name,$source_name);
+ if($id_from_db == -1){
+ $query = "INSERT INTO image_source(source_name,url,contact_email,contributor_name) VALUES('$source_name','$url','$contact_email','$contributor_name')";
+ $rsrcResult = mysql_query($query);
+ if (!$rsrcResult) {
+ echo "DB Error while trying to add new image source information\n";
+ echo 'MySQL Error: ' . mysql_error();
+ exit();
+ }
+ $id_from_db = get_image_source_id($contributor_name,$source_name);
+ }
+ return $id_from_db;
+ }
+
+ function get_image_source_id($contributor_name,$source_name){
+ $query = "select image_source_id from image_source where contributor_name='$contributor_name' and source_name='$source_name'";
+ $row = getRowFromDB($query,"image source id");
+ if(count($row) == 0 || (count($row) > 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<br/>";
+ echo "<a href='data.html'>Click here to upload annotated image data file</a>";
+ }
+ else{
+ echo "Couldn't save information";
+ exit();
+ }
+ }
+
+?>
--- /dev/null
+<html>
+<head>
+<title>Tool for uploading image annotation information</title>
+</head>
+<body>
+<center><h1>Tool for uploading image annotation information</h1></center>
+<h2>Step 2</h2>
+<p>Please upload the image annotation information file below</p>
+<br/><br/><br/>
+<form action="data_process.php" method="post" enctype="multipart/form-data">
+ <label for="file">Contact information file:</label>
+ <input type="file" name="file" id="file" />
+ <br />
+ <input type="submit" name="submit" value="Submit" />
+</form>
+
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<title>Tool for uploading image annotation information</title>
+</head>
+<body>
+<center><h1>Tool for uploading image annotation information</h1></center>
+<h2>Step 1</h2>
+<p>Please upload the contact information file below</p>
+<br/><br/><br/>
+<form action="contact_process.php" method="post" enctype="multipart/form-data">
+ <label for="file">Contact information file:</label>
+ <input type="file" name="file" id="file" />
+ <br />
+ <input type="submit" name="submit" value="Submit" />
+</form>
+
+</body>
+</html>
+++ /dev/null
-<?php
-
- //db config values
- $dbHost = "localhost";
- $dbUser = "root";
- $dbPwd = "root";
- $connection = mysql_connect($dbHost,$dbUser,$dbPwd);
- mysql_select_db("image_annotation");
-
- function getRowFromDB($query,$value){
- $rsrcResult = mysql_query($query);
- if (!$rsrcResult) {
- echo "DB Error while trying to retrieve $value\n MySQL Error: ".mysql_error();
- exit();
- }
- $row = mysql_fetch_row($rsrcResult);
- return $row;
- }
-
- function save_image_source_information($contact){
- $contributor_name = $contact['contributor_name'];
- $source_name = $contact['source_name'];
- $url = $contact['url'];
- $contact_email = $contact['contact_email'];
- $id_from_db = get_image_source_id($contributor_name,$source_name);
- if($id_from_db == -1){
- $query = "INSERT INTO image_source(source_name,url,contact_email,contributor_name) VALUES('$source_name','$url','$contact_email','$contributor_name')";
- $rsrcResult = mysql_query($query);
- if (!$rsrcResult) {
- echo "DB Error while trying to add new image source information\n";
- echo 'MySQL Error: ' . mysql_error();
- exit();
- }
- $id_from_db = get_image_source_id($contributor_name,$source_name);
- }
- return $id_from_db;
- }
-
- function get_image_source_id($contributor_name,$source_name){
- $query = "select image_source_id from image_source where contributor_name='$contributor_name' and source_name='$source_name'";
- $row = getRowFromDB($query,"image source id");
- if(count($row) == 0 || (count($row) > 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<br/>";
- echo "<a href='data.html'>Click here to upload annotated image data file</a>";
- }
- else{
- echo "Couldn't save information";
- exit();
- }
- }
-
-?>
+++ /dev/null
-<html>
-<head>
-<title>Tool for uploading image annotation information</title>
-</head>
-<body>
-<center><h1>Tool for uploading image annotation information</h1></center>
-<h2>Step 2</h2>
-<p>Please upload the image annotation information file below</p>
-<br/><br/><br/>
-<form action="data_process.php" method="post" enctype="multipart/form-data">
- <label for="file">Contact information file:</label>
- <input type="file" name="file" id="file" />
- <br />
- <input type="submit" name="submit" value="Submit" />
-</form>
-
-</body>
-</html>
--- /dev/null
+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
+++ /dev/null
-<html>
-<head>
-<title>Tool for uploading image annotation information</title>
-</head>
-<body>
-<center><h1>Tool for uploading image annotation information</h1></center>
-<h2>Step 1</h2>
-<p>Please upload the contact information file below</p>
-<br/><br/><br/>
-<form action="contact_process.php" method="post" enctype="multipart/form-data">
- <label for="file">Contact information file:</label>
- <input type="file" name="file" id="file" />
- <br />
- <input type="submit" name="submit" value="Submit" />
-</form>
-
-</body>
-</html>
+++ /dev/null
-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;
+++ /dev/null
-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;
--- /dev/null
+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;
--- /dev/null
+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;