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,ALLOW_INVALID_DATES';

CREATE SCHEMA IF NOT EXISTS `VegCore` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ;
USE `VegCore` ;

-- -----------------------------------------------------
-- Table `source`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `source` ;

CREATE  TABLE IF NOT EXISTS `source` (
  `id` VARBINARY(767) NOT NULL ,
  `parent` VARBINARY(767) NOT NULL ,
  `name` VARBINARY(767) NOT NULL ,
  `first_publisher` VARBINARY(767) NULL DEFAULT NULL ,
  `owner` VARBINARY(767) NULL DEFAULT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_source1_idx` (`parent` ASC) ,
  INDEX `fk_source_party1_idx` (`owner` ASC) ,
  UNIQUE INDEX `source_unique` (`parent` ASC, `name` ASC) ,
  INDEX `fk_source_party2_idx` (`first_publisher` ASC) ,
  CONSTRAINT `fk_source1`
    FOREIGN KEY (`parent` )
    REFERENCES `source` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_source_party1`
    FOREIGN KEY (`owner` )
    REFERENCES `party` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_source_party2`
    FOREIGN KEY (`first_publisher` )
    REFERENCES `party` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'a \"reference [...] cited within the database\" (\"VegBank\":http://vegbank.org/vegbank/views/dba_tabledescription_detail.jsp?view=detail&wparam=reference&entity=dba_tabledescription&where=where_tablename)';


-- -----------------------------------------------------
-- Table `record`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `record` ;

CREATE  TABLE IF NOT EXISTS `record` (
  `id` VARBINARY(767) NOT NULL ,
  `source` VARBINARY(767) NOT NULL ,
  `source_id_scope` VARBINARY(767) NULL ,
  `source_record_id` VARBINARY(767) NULL DEFAULT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_record_source1_idx` (`source` ASC) ,
  UNIQUE INDEX `record_unique` (`source` ASC, `source_id_scope` ASC, `source_record_id` ASC) ,
  CONSTRAINT `fk_record_source1`
    FOREIGN KEY (`source` )
    REFERENCES `source` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `party`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `party` ;

CREATE  TABLE IF NOT EXISTS `party` (
  `id` VARBINARY(767) NOT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_collection_source10`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `relationship`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `relationship` ;

CREATE  TABLE IF NOT EXISTS `relationship` (
  `id` VARBINARY(767) NOT NULL ,
  `record` VARBINARY(767) NOT NULL ,
  `related_record` VARBINARY(767) NOT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_relationship_record1_idx` (`record` ASC) ,
  INDEX `fk_relationship_related_record_idx` (`related_record` ASC) ,
  CONSTRAINT `fk_relationship_record1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_relationship_record2`
    FOREIGN KEY (`record` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_relationship_related_record`
    FOREIGN KEY (`related_record` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"information pertaining to relationships between resources (instances of data records, such as Occurrences, Taxa, Locations, Events)\" (\"DwC\":http://rs.tdwg.org/dwc/terms/#ResourceRelationship)';


-- -----------------------------------------------------
-- Table `organization`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `organization` ;

CREATE  TABLE IF NOT EXISTS `organization` (
  `id` VARBINARY(767) NOT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_organization_party1`
    FOREIGN KEY (`id` )
    REFERENCES `party` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `collection`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `collection` ;

CREATE  TABLE IF NOT EXISTS `collection` (
  `id` VARBINARY(767) NOT NULL ,
  `institution` VARBINARY(767) NOT NULL ,
  `name` VARBINARY(767) NOT NULL ,
  INDEX `fk_collection_organization1_idx` (`institution` ASC) ,
  UNIQUE INDEX `collection_unique` (`institution` ASC, `name` ASC) ,
  INDEX `fk_collection_source1_idx` (`id` ASC) ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_collection_source1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_collection_organization1`
    FOREIGN KEY (`institution` )
    REFERENCES `organization` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"the collection within the institution where a specimen is held\" (\"Brad Boyle\":https://projects.nceas.ucsb.edu/nceas/attachments/download/621/vegbien_identifier_examples.xlsx#terms/collectionCode)';


-- -----------------------------------------------------
-- Table `taxon_assertion`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_assertion` ;

CREATE  TABLE IF NOT EXISTS `taxon_assertion` (
  `id` VARBINARY(767) NOT NULL ,
  `string` VARBINARY(767) NOT NULL ,
  `taxon` VARBINARY(767) NULL DEFAULT NULL ,
  `cf_aff` VARBINARY(767) NULL DEFAULT NULL ,
  `annotations` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_taxon_assertion_taxon_string1_idx` (`string` ASC) ,
  INDEX `fk_taxon_assertion_taxon_name1_idx` (`taxon` ASC) ,
  CONSTRAINT `fk_qualified_taxon_record1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_assertion_taxon_string1`
    FOREIGN KEY (`string` )
    REFERENCES `taxon_string` (`string` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_assertion_taxon_name1`
    FOREIGN KEY (`taxon` )
    REFERENCES `taxon_name` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `taxon_concept`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_concept` ;

CREATE  TABLE IF NOT EXISTS `taxon_concept` (
  `id` VARBINARY(767) NOT NULL ,
  `according_to` VARBINARY(767) NOT NULL ,
  `parent` VARBINARY(767) NOT NULL ,
  `accepted_taxon_concept` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_taxon_taxon1_idx` (`parent` ASC) ,
  INDEX `fk_taxon_concept_source1_idx` (`according_to` ASC) ,
  INDEX `fk_taxon_concept_taxon_concept1_idx` (`accepted_taxon_concept` ASC) ,
  UNIQUE INDEX `taxon_concept_unique_name` (`according_to` ASC) ,
  CONSTRAINT `fk_taxon_taxon1`
    FOREIGN KEY (`parent` )
    REFERENCES `taxon_concept` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_concept_source1`
    FOREIGN KEY (`according_to` )
    REFERENCES `source` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_concept_taxon_concept1`
    FOREIGN KEY (`accepted_taxon_concept` )
    REFERENCES `taxon_concept` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_concept_taxon_name1`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_name` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'A [[VegCore#Taxon|Taxon]] described by a specific [[VegCore#Reference|Reference]]';


-- -----------------------------------------------------
-- Table `parsed_taxon_assertion`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `parsed_taxon_assertion` ;

CREATE  TABLE IF NOT EXISTS `parsed_taxon_assertion` (
  `id` VARBINARY(767) NOT NULL ,
  `matched_taxon_concept` VARBINARY(767) NULL DEFAULT NULL ,
  `match_score` FLOAT NULL ,
  `match_info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_parsed_taxon_assertion_taxon_name1_idx` (`matched_taxon_concept` ASC) ,
  CONSTRAINT `fk_matched_taxon_qualified_taxon10`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_assertion` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_parsed_taxon_assertion_taxon_name1`
    FOREIGN KEY (`matched_taxon_concept` )
    REFERENCES `taxon_concept` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `taxon_string`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_string` ;

CREATE  TABLE IF NOT EXISTS `taxon_string` (
  `string` VARBINARY(767) NOT NULL ,
  `parsed_taxon_assertion` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`string`) ,
  INDEX `fk_taxon_string_parsed_taxon_assertion1_idx` (`parsed_taxon_assertion` ASC) ,
  CONSTRAINT `fk_taxon_string_parsed_taxon_assertion1`
    FOREIGN KEY (`parsed_taxon_assertion` )
    REFERENCES `parsed_taxon_assertion` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `taxon_name`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_name` ;

CREATE  TABLE IF NOT EXISTS `taxon_name` (
  `id` VARBINARY(767) NOT NULL ,
  `unique_name` VARBINARY(767) NOT NULL ,
  `formal_name` VARBINARY(767) NULL DEFAULT NULL ,
  `taxon_name` VARBINARY(767) NULL DEFAULT NULL ,
  `author` VARBINARY(767) NULL DEFAULT NULL ,
  `common_name` VARBINARY(767) NULL DEFAULT NULL ,
  `rank` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_taxon_concept_taxon_string10_idx` (`unique_name` ASC) ,
  CONSTRAINT `fk_taxon_record10`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_concept_taxon_string10`
    FOREIGN KEY (`unique_name` )
    REFERENCES `taxon_string` (`string` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `coordinates`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `coordinates` ;

CREATE  TABLE IF NOT EXISTS `coordinates` (
  `id` VARBINARY(767) NOT NULL ,
  `latitude_deg` VARBINARY(767) NULL DEFAULT NULL ,
  `longitude_deg` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'A numerically-defined point';


-- -----------------------------------------------------
-- Table `place_path`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `place_path` ;

CREATE  TABLE IF NOT EXISTS `place_path` (
  `id` VARBINARY(767) NOT NULL ,
  `continent` VARBINARY(767) NULL DEFAULT NULL ,
  `country` VARBINARY(767) NULL DEFAULT NULL ,
  `state_province` VARBINARY(767) NULL DEFAULT NULL ,
  `county` VARBINARY(767) NULL DEFAULT NULL ,
  `municipality` VARBINARY(767) NULL DEFAULT NULL ,
  `ranks` SET('hstore') NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'A named region';


-- -----------------------------------------------------
-- Table `place`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `place` ;

CREATE  TABLE IF NOT EXISTS `place` (
  `id` VARBINARY(767) NOT NULL ,
  `parent` VARBINARY(767) NOT NULL ,
  `coordinates` VARBINARY(767) NULL DEFAULT NULL ,
  `path` VARBINARY(767) NULL DEFAULT NULL ,
  `locality` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_place_coordinates1_idx` (`coordinates` ASC) ,
  INDEX `fk_place1_idx` (`parent` ASC) ,
  INDEX `fk_place_place_path1_idx` (`path` ASC) ,
  CONSTRAINT `fk_place_record1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_place_coordinates1`
    FOREIGN KEY (`coordinates` )
    REFERENCES `coordinates` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_place1`
    FOREIGN KEY (`parent` )
    REFERENCES `place` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_place_place_path1`
    FOREIGN KEY (`path` )
    REFERENCES `place_path` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"A spatial region\" (\"DwC\":http://rs.tdwg.org/dwc/terms/#dcterms:Location) or point';


-- -----------------------------------------------------
-- Table `method`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `method` ;

CREATE  TABLE IF NOT EXISTS `method` (
  `id` VARBINARY(767) NOT NULL ,
  `parent` VARBINARY(767) NOT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_method_method1_idx` (`parent` ASC) ,
  CONSTRAINT `fk_method_record1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_method_method1`
    FOREIGN KEY (`parent` )
    REFERENCES `method` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"A specific method definition followed in the creation of the dataset. Each method links to a protocol and literature citation reference. A protocol may have many method or steps.\" (\"VegX\":http://wiki.tdwg.org/twiki/pub/Vegetation/WebHome/VegX_Schema_1.5.3_proposed.zip#/veg.xsd#/methods/method)';


-- -----------------------------------------------------
-- Table `event`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `event` ;

CREATE  TABLE IF NOT EXISTS `event` (
  `id` VARBINARY(767) NOT NULL ,
  `parent` VARBINARY(767) NOT NULL ,
  `name` VARBINARY(767) NULL DEFAULT NULL ,
  `date_range` VARBINARY(767) NULL DEFAULT NULL ,
  `place` VARBINARY(767) NULL DEFAULT NULL ,
  `method` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_event_place1_idx` (`place` ASC) ,
  INDEX `fk_event1_idx` (`parent` ASC) ,
  INDEX `fk_event_method1_idx` (`method` ASC) ,
  CONSTRAINT `fk_event_record1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_event_place1`
    FOREIGN KEY (`place` )
    REFERENCES `place` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_event1`
    FOREIGN KEY (`parent` )
    REFERENCES `event` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_event_method1`
    FOREIGN KEY (`method` )
    REFERENCES `method` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"an action that occurs at a place and during a period of time\" (\"DwC\":http://rs.tdwg.org/dwc/terms/#Event)';


-- -----------------------------------------------------
-- Table `specimen`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `specimen` ;

CREATE  TABLE IF NOT EXISTS `specimen` (
  `id` VARBINARY(767) NOT NULL ,
  `individual` VARBINARY(767) NULL ,
  `code_in_individual` VARBINARY(767) NULL ,
  `collection_event` VARBINARY(767) NULL ,
  `orig_collection` VARBINARY(767) NULL DEFAULT NULL ,
  `barcode` VARBINARY(767) NULL DEFAULT NULL ,
  `accession_number` VARBINARY(767) NULL DEFAULT NULL ,
  `current_collection` VARBINARY(767) NULL ,
  `owner_collection` VARBINARY(767) NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_specimen_collection1_idx` (`orig_collection` ASC) ,
  INDEX `fk_specimen_taxon_observation1_idx` (`collection_event` ASC) ,
  INDEX `fk_specimen_individual1_idx` (`individual` ASC) ,
  INDEX `fk_specimen_collection2_idx` (`current_collection` ASC) ,
  INDEX `fk_specimen_organization3_idx` (`owner_collection` ASC) ,
  UNIQUE INDEX `specimen_unique_in_individual` (`individual` ASC, `code_in_individual` ASC) ,
  UNIQUE INDEX `specimen_unique_by_collection_event` (`collection_event` ASC) ,
  UNIQUE INDEX `specimen_unique_in_collection_by_barcode` (`orig_collection` ASC, `barcode` ASC) ,
  UNIQUE INDEX `specimen_unique_in_collection_by_accession_number` (`orig_collection` ASC, `accession_number` ASC) ,
  CONSTRAINT `fk_specimen_taxon_occurrence1`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_occurrence` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_specimen_collection1`
    FOREIGN KEY (`orig_collection` )
    REFERENCES `collection` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_specimen_organization3`
    FOREIGN KEY (`owner_collection` )
    REFERENCES `collection` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_specimen_taxon_observation1`
    FOREIGN KEY (`collection_event` )
    REFERENCES `taxon_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_specimen_individual1`
    FOREIGN KEY (`individual` )
    REFERENCES `individual` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_specimen_collection2`
    FOREIGN KEY (`current_collection` )
    REFERENCES `collection` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'A \"part of a plant\" (\"Wikipedia\":http://en.wikipedia.org/wiki/Specimen) which was collected from it';


-- -----------------------------------------------------
-- Table `taxon_observation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_observation` ;

CREATE  TABLE IF NOT EXISTS `taxon_observation` (
  `id` VARBINARY(767) NOT NULL ,
  `taxon_occurrence` VARBINARY(767) NOT NULL ,
  `collector` VARBINARY(767) NULL ,
  `collector_number` VARBINARY(767) NULL ,
  `voucher` VARBINARY(767) NULL DEFAULT NULL ,
  `growth_form` VARBINARY(767) NULL DEFAULT NULL ,
  `cultivated` TINYINT(1) NULL ,
  `traits` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_taxon_observation_taxon_occurrence2_idx` (`taxon_occurrence` ASC) ,
  INDEX `fk_taxon_observation_specimen1_idx` (`voucher` ASC) ,
  INDEX `fk_taxon_observation_party1_idx` (`collector` ASC) ,
  CONSTRAINT `fk_taxon_observation_event1`
    FOREIGN KEY (`id` )
    REFERENCES `event` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_observation_taxon_occurrence2`
    FOREIGN KEY (`taxon_occurrence` )
    REFERENCES `taxon_occurrence` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_observation_specimen1`
    FOREIGN KEY (`voucher` )
    REFERENCES `specimen` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_observation_party1`
    FOREIGN KEY (`collector` )
    REFERENCES `party` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `taxon_determination`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_determination` ;

CREATE  TABLE IF NOT EXISTS `taxon_determination` (
  `id` VARBINARY(767) NOT NULL ,
  `taxon_assertion` VARBINARY(767) NOT NULL ,
  `identified_by` VARBINARY(767) NULL DEFAULT NULL ,
  `fit_info` SET('hstore') NULL ,
  INDEX `fk_taxon_occurrence_has_qualified_taxon1_idx` (`taxon_assertion` ASC) ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_taxon_determination_party1_idx` (`identified_by` ASC) ,
  UNIQUE INDEX `taxon_determination_unique` (`taxon_assertion` ASC, `identified_by` ASC) ,
  CONSTRAINT `fk_taxon_occurrence_has_qualified_taxon1`
    FOREIGN KEY (`taxon_assertion` )
    REFERENCES `taxon_assertion` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_determination_record1`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_determination_party1`
    FOREIGN KEY (`identified_by` )
    REFERENCES `party` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'An assertion that a [[VegCore#TaxonOccurrence|TaxonOccurrence]] is a particular [[VegCore#Taxon|Taxon]]';


-- -----------------------------------------------------
-- Table `taxon_occurrence`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_occurrence` ;

CREATE  TABLE IF NOT EXISTS `taxon_occurrence` (
  `id` VARBINARY(767) NOT NULL ,
  `current_determination` VARBINARY(767) NULL DEFAULT NULL ,
  `original_determination` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_taxon_occurrence_taxon_determination1_idx` (`original_determination` ASC) ,
  INDEX `fk_taxon_occurrence_taxon_determination2_idx` (`current_determination` ASC) ,
  CONSTRAINT `fk_taxon_occurrence_taxon_determination1`
    FOREIGN KEY (`original_determination` )
    REFERENCES `taxon_determination` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_occurrence_taxon_determination2`
    FOREIGN KEY (`current_determination` )
    REFERENCES `taxon_determination` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_occurrence_event1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'Any entity on which [[VegCore#TaxonDetermination|TaxonDetermination]]s can be made';


-- -----------------------------------------------------
-- Table `individual`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `individual` ;

CREATE  TABLE IF NOT EXISTS `individual` (
  `id` VARBINARY(767) NOT NULL ,
  `tag` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_individual_record1`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_occurrence` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'A distinct biological organism';


-- -----------------------------------------------------
-- Table `aggregate_observation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `aggregate_observation` ;

CREATE  TABLE IF NOT EXISTS `aggregate_observation` (
  `id` VARBINARY(767) NOT NULL ,
  `taxon_concept` VARBINARY(767) NOT NULL ,
  `traits` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_aggregate_observation_taxon_name1_idx` (`taxon_concept` ASC) ,
  CONSTRAINT `fk_aggregate_observation_taxon_occurrence1`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_aggregate_observation_taxon_name1`
    FOREIGN KEY (`taxon_concept` )
    REFERENCES `taxon_concept` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"An observation applying to all occurrences of an organism based on an aggregation factor\" (\"VegX\":http://wiki.tdwg.org/twiki/pub/Vegetation/WebHome/VegX_Schema_1.5.3_proposed.zip#/veg.xsd#/aggregateOrganismObservations/aggregateOrganismObservation)';


-- -----------------------------------------------------
-- Table `taxon_presence`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_presence` ;

CREATE  TABLE IF NOT EXISTS `taxon_presence` (
  `id` VARBINARY(767) NOT NULL ,
  `taxon_concept` VARBINARY(767) NOT NULL ,
  `traits` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_taxon_presence_taxon_name1_idx` (`taxon_concept` ASC) ,
  CONSTRAINT `fk_taxon_observation_taxon_occurrence1`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_taxon_presence_taxon_name1`
    FOREIGN KEY (`taxon_concept` )
    REFERENCES `taxon_concept` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'An observation of just a [[VegCore#Taxon|Taxon]]\'s _presence_';


-- -----------------------------------------------------
-- Table `community`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `community` ;

CREATE  TABLE IF NOT EXISTS `community` (
  `id` VARBINARY(767) NOT NULL ,
  `name` VARBINARY(767) NOT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_community_record1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"A community type is an abstract grouping of organisms that tend to co-occur on the landscape due to shared ecological requirements or preferences. May be designated by syntaxon or physiognomic types.\" ([[VegCore#VegX|VegX]])';


-- -----------------------------------------------------
-- Table `geological_context`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `geological_context` ;

CREATE  TABLE IF NOT EXISTS `geological_context` (
  `id` VARBINARY(767) NOT NULL ,
  `name` VARBINARY(767) NOT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_geological_context_record1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"information pertaining to a location within a geological context, such as stratigraphy\" (\"DwC\":http://rs.tdwg.org/dwc/terms/#GeologicalContext)';


-- -----------------------------------------------------
-- Table `place_observation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `place_observation` ;

CREATE  TABLE IF NOT EXISTS `place_observation` (
  `id` VARBINARY(767) NOT NULL ,
  `place` VARBINARY(767) NOT NULL ,
  `elevation_m` DOUBLE NULL ,
  `slope_incline_deg` DOUBLE NULL ,
  `slope_direction_deg_N` DOUBLE NULL ,
  `geological_context` VARBINARY(767) NULL DEFAULT NULL ,
  `community` VARBINARY(767) NULL DEFAULT NULL ,
  `observations` SET('hstore') NULL ,
  INDEX `fk_place_observation_place1_idx` (`place` ASC) ,
  INDEX `fk_place_observation_geological_context1_idx` (`geological_context` ASC) ,
  INDEX `fk_place_observation_community1_idx` (`community` ASC) ,
  INDEX `fk_place_observation_event1_idx` (`id` ASC) ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_place_observation_place1`
    FOREIGN KEY (`place` )
    REFERENCES `place` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_place_observation_geological_context1`
    FOREIGN KEY (`geological_context` )
    REFERENCES `geological_context` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_place_observation_community1`
    FOREIGN KEY (`community` )
    REFERENCES `community` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_place_observation_event1`
    FOREIGN KEY (`id` )
    REFERENCES `event` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'A sampling of a [[VegCore#Location|Location]]';


-- -----------------------------------------------------
-- Table `soil_observation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `soil_observation` ;

CREATE  TABLE IF NOT EXISTS `soil_observation` (
  `id` VARBINARY(767) NOT NULL ,
  `observations` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_soil_observation_place_observation1`
    FOREIGN KEY (`id` )
    REFERENCES `place_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'A sampling of a [[VegCore#Location|Location]]\'s soil';


-- -----------------------------------------------------
-- Table `plot`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `plot` ;

CREATE  TABLE IF NOT EXISTS `plot` (
  `id` VARBINARY(767) NOT NULL ,
  `name` VARBINARY(767) NULL DEFAULT NULL ,
  `area_m2` DOUBLE NULL ,
  `bounding_box` VARBINARY(767) NULL DEFAULT NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_subplot_place1`
    FOREIGN KEY (`id` )
    REFERENCES `place` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `subplot`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `subplot` ;

CREATE  TABLE IF NOT EXISTS `subplot` (
  `id` VARBINARY(767) NOT NULL ,
  `x_m` DOUBLE NULL ,
  `y_m` DOUBLE NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_subplot_plot1`
    FOREIGN KEY (`id` )
    REFERENCES `plot` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"subplot, line, or any other subsample  or subdivision of plot\" (\"SALVIAS\":http://salvias.net/Documents/salvias_data_dictionary.html#Plot_data/subplot)';


-- -----------------------------------------------------
-- Table `validatable_place`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `validatable_place` ;

CREATE  TABLE IF NOT EXISTS `validatable_place` (
  `id` VARBINARY(767) NOT NULL ,
  `coordinates` VARBINARY(767) NOT NULL ,
  `path` VARBINARY(767) NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_geovalidation_place_path1_idx` (`path` ASC) ,
  INDEX `fk_geovalidation_coordinates1_idx` (`coordinates` ASC) ,
  UNIQUE INDEX `validatable_place_unique` (`path` ASC, `coordinates` ASC) ,
  CONSTRAINT `fk_geovalidation_place_path1`
    FOREIGN KEY (`path` )
    REFERENCES `place_path` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_geovalidation_coordinates1`
    FOREIGN KEY (`coordinates` )
    REFERENCES `coordinates` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `individual_observation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `individual_observation` ;

CREATE  TABLE IF NOT EXISTS `individual_observation` (
  `id` VARBINARY(767) NOT NULL ,
  `individual` VARBINARY(767) NULL ,
  `code` VARBINARY(767) NULL ,
  `traits` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_individual_observation_individual1_idx` (`individual` ASC) ,
  CONSTRAINT `fk_individual_observation_taxon_occurrence1`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_individual_observation_individual1`
    FOREIGN KEY (`individual` )
    REFERENCES `individual` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'An observation of an [[VegCore#Individual|Individual]]';


-- -----------------------------------------------------
-- Table `stem`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `stem` ;

CREATE  TABLE IF NOT EXISTS `stem` (
  `id` VARBINARY(767) NOT NULL ,
  `individual` VARBINARY(767) NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_stem_individual1_idx` (`individual` ASC) ,
  CONSTRAINT `fk_stem_individual1`
    FOREIGN KEY (`individual` )
    REFERENCES `individual` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_stem_individual2`
    FOREIGN KEY (`id` )
    REFERENCES `individual` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'An \"individual tree stem\" (\"VegBank\":http://vegbank.org/vegbank/views/dba_tabledescription_detail.jsp?view=detail&wparam=stemlocation&entity=dba_tabledescription&where=where_tablename)';


-- -----------------------------------------------------
-- Table `stem_observation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `stem_observation` ;

CREATE  TABLE IF NOT EXISTS `stem_observation` (
  `id` VARBINARY(767) NOT NULL ,
  `individual_observation` VARBINARY(767) NOT NULL ,
  `stem` VARBINARY(767) NULL ,
  `traits` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_stem_observation_individual_observation1_idx` (`individual_observation` ASC) ,
  INDEX `fk_stem_observation_stem1_idx` (`stem` ASC) ,
  UNIQUE INDEX `stem_observation_unique` (`individual_observation` ASC, `stem` ASC) ,
  CONSTRAINT `fk_stem_observation_individual_observation1`
    FOREIGN KEY (`individual_observation` )
    REFERENCES `individual_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_stem_observation_stem1`
    FOREIGN KEY (`stem` )
    REFERENCES `stem` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_stem_observation_individual_observation2`
    FOREIGN KEY (`id` )
    REFERENCES `individual_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'An observation of a [[VegCore#Stem|Stem]]';


-- -----------------------------------------------------
-- Table `project`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `project` ;

CREATE  TABLE IF NOT EXISTS `project` (
  `id` VARBINARY(767) NOT NULL ,
  `name` VARBINARY(767) NOT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_project_event1`
    FOREIGN KEY (`id` )
    REFERENCES `event` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'A \"project established to collect vegetation plot data. Each plot originates as part of a project.\" (\"VegBank\":http://vegbank.org/vegbank/views/dba_tabledescription_detail.jsp?view=detail&wparam=project&entity=dba_tabledescription&where=where_tablename)';


-- -----------------------------------------------------
-- Table `referenced_class`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `referenced_class` ;

CREATE  TABLE IF NOT EXISTS `referenced_class` (
  `id` VARBINARY(767) NOT NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_example_record10`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `base_class`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `base_class` ;

CREATE  TABLE IF NOT EXISTS `base_class` (
  `id` VARBINARY(767) NOT NULL ,
  `referenced_class` VARBINARY(767) NOT NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_base_class_referenced_class1_idx` (`referenced_class` ASC) ,
  CONSTRAINT `fk_example_record1`
    FOREIGN KEY (`id` )
    REFERENCES `record` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_base_class_referenced_class1`
    FOREIGN KEY (`referenced_class` )
    REFERENCES `referenced_class` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `derived_class`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `derived_class` ;

CREATE  TABLE IF NOT EXISTS `derived_class` (
  `id` VARBINARY(767) NOT NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_derived_class_base_class1`
    FOREIGN KEY (`id` )
    REFERENCES `base_class` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `stratum`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `stratum` ;

CREATE  TABLE IF NOT EXISTS `stratum` (
  `id` VARBINARY(767) NOT NULL ,
  `name` VARBINARY(767) NOT NULL ,
  `info` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_place_path_record10`
    FOREIGN KEY (`id` )
    REFERENCES `method` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `geovalidation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `geovalidation` ;

CREATE  TABLE IF NOT EXISTS `geovalidation` (
  `id` VARBINARY(767) NOT NULL ,
  `geovalid` TINYINT(1) NOT NULL ,
  `lat_long_domain_valid` TINYINT(1) NOT NULL ,
  `lat_long_in_ranks` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_geovalidation_validatable_place1`
    FOREIGN KEY (`id` )
    REFERENCES `validatable_place` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = 'The accuracy of the [[VegCore#Coordinates|Coordinates]], taking into account the [[VegCore#Placename|Placename]]';


-- -----------------------------------------------------
-- Table `taxon_path`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `taxon_path` ;

CREATE  TABLE IF NOT EXISTS `taxon_path` (
  `id` VARBINARY(767) NOT NULL ,
  `family` VARBINARY(767) NULL DEFAULT NULL ,
  `genus` VARBINARY(767) NULL DEFAULT NULL ,
  `specific_epithet` VARBINARY(767) NULL DEFAULT NULL ,
  `ranks` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_taxon_path_taxon_name1`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_name` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin
COMMENT = '\"a group of one (or more) populations of organism(s), which a taxonomist adjudges to be a unit\" (\"Wikipedia\":http://en.wikipedia.org/wiki/Taxon)';


-- -----------------------------------------------------
-- Table `specimen_observation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `specimen_observation` ;

CREATE  TABLE IF NOT EXISTS `specimen_observation` (
  `id` VARBINARY(767) NOT NULL ,
  `specimen` VARBINARY(767) NOT NULL ,
  `traits` SET('hstore') NULL ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_specimen_observation_specimen1_idx` (`specimen` ASC) ,
  CONSTRAINT `fk_specimen_taxon_occurrence10`
    FOREIGN KEY (`id` )
    REFERENCES `taxon_observation` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_specimen_observation_specimen1`
    FOREIGN KEY (`specimen` )
    REFERENCES `specimen` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `event_participant`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `event_participant` ;

CREATE  TABLE IF NOT EXISTS `event_participant` (
  `event` VARBINARY(767) NOT NULL ,
  `party` VARBINARY(767) NOT NULL ,
  `sort_order` INT NULL ,
  PRIMARY KEY (`event`, `party`) ,
  INDEX `fk_event_has_party_party1_idx` (`party` ASC) ,
  INDEX `fk_event_has_party_event1_idx` (`event` ASC) ,
  CONSTRAINT `fk_event_has_party_event1`
    FOREIGN KEY (`event` )
    REFERENCES `event` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_event_has_party_party1`
    FOREIGN KEY (`party` )
    REFERENCES `party` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;


-- -----------------------------------------------------
-- Table `specimenholder_institution`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `specimenholder_institution` ;

CREATE  TABLE IF NOT EXISTS `specimenholder_institution` (
  `specimen` VARBINARY(767) NOT NULL ,
  `institution` VARBINARY(767) NOT NULL ,
  `sort_order` INT NULL ,
  PRIMARY KEY (`specimen`, `institution`) ,
  INDEX `fk_specimen_has_organization_organization1_idx` (`institution` ASC) ,
  INDEX `fk_specimen_has_organization_specimen1_idx` (`specimen` ASC) ,
  CONSTRAINT `fk_specimen_has_organization_specimen1`
    FOREIGN KEY (`specimen` )
    REFERENCES `specimen` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_specimen_has_organization_organization1`
    FOREIGN KEY (`institution` )
    REFERENCES `organization` (`id` )
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_bin;

USE `VegCore` ;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
