-- phpMyAdmin SQL Dump
-- version 3.4.6
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Feb 24, 2012 at 02:12 PM
-- Server version: 5.5.16
-- PHP Version: 5.3.8

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `CTFS`
--

-- --------------------------------------------------------

--
-- Table structure for table `Census`
--

CREATE TABLE IF NOT EXISTS `Census` (
  `CensusID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `PlotID` int(10) unsigned NOT NULL,
  `PlotCensusNumber` int(11) DEFAULT NULL,
  `StartDate` date DEFAULT NULL,
  `EndDate` date DEFAULT NULL,
  `Description` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`CensusID`),
  KEY `Ref610` (`PlotID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=200 ;

-- --------------------------------------------------------

--
-- Table structure for table `CensusQuadrat`
--

CREATE TABLE IF NOT EXISTS `CensusQuadrat` (
  `CensusID` int(10) unsigned NOT NULL,
  `QuadratID` int(10) unsigned NOT NULL,
  `PlotID` int(10) unsigned NOT NULL,
  PRIMARY KEY (`CensusID`,`QuadratID`,`PlotID`),
  KEY `Ref733` (`QuadratID`,`PlotID`),
  KEY `Ref534` (`CensusID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `Country`
--

CREATE TABLE IF NOT EXISTS `Country` (
  `CountryID` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `CountryName` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`CountryID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

-- --------------------------------------------------------

--
-- Table structure for table `CurrentObsolete`
--

CREATE TABLE IF NOT EXISTS `CurrentObsolete` (
  `SpeciesID` int(10) unsigned NOT NULL,
  `ObsoleteSpeciesID` int(10) unsigned NOT NULL,
  `ChangeDate` datetime NOT NULL,
  `ChangeCodeID` int(10) unsigned NOT NULL,
  `ChangeNote` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`SpeciesID`,`ObsoleteSpeciesID`,`ChangeDate`),
  KEY `Ref32191` (`ChangeCodeID`),
  KEY `Ref92192` (`SpeciesID`),
  KEY `Ref92212` (`ObsoleteSpeciesID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `DataCollection`
--

CREATE TABLE IF NOT EXISTS `DataCollection` (
  `PersonnelID` smallint(5) unsigned NOT NULL,
  `RoleID` smallint(5) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `QuadratID` int(10) unsigned NOT NULL,
  `PlotID` int(10) unsigned NOT NULL,
  `StartDate` date DEFAULT NULL,
  `EndDate` date DEFAULT NULL,
  PRIMARY KEY (`PersonnelID`,`RoleID`,`CensusID`,`QuadratID`,`PlotID`),
  KEY `Ref3883` (`RoleID`),
  KEY `Ref1743` (`CensusID`,`QuadratID`,`PlotID`),
  KEY `Ref1544` (`PersonnelID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `DataEntry`
--

CREATE TABLE IF NOT EXISTS `DataEntry` (
  `PersonnelID` smallint(5) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `QuadratID` int(10) unsigned NOT NULL,
  `PlotID` int(10) unsigned NOT NULL,
  `StartDate` date DEFAULT NULL,
  `EndDate` date DEFAULT NULL,
  PRIMARY KEY (`PersonnelID`,`CensusID`,`QuadratID`,`PlotID`),
  KEY `Ref1745` (`CensusID`,`QuadratID`,`PlotID`),
  KEY `Ref1547` (`PersonnelID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `DFtemp`
--

CREATE TABLE IF NOT EXISTS `DFtemp` (
  `MeasureID` int(11) NOT NULL,
  `PlotID` int(11) NOT NULL,
  `Plot` varchar(35) DEFAULT NULL,
  `Family` char(32) DEFAULT NULL,
  `GenusSpecies` char(64) DEFAULT NULL,
  `Genus` char(32) DEFAULT NULL,
  `SpeciesName` char(64) DEFAULT NULL,
  `SpeciesID` int(10) unsigned DEFAULT NULL,
  `Mnemonic` char(10) DEFAULT NULL,
  `QuadratID` int(11) NOT NULL,
  `QuadratName` varchar(12) DEFAULT NULL,
  `x` float DEFAULT NULL,
  `y` float DEFAULT NULL,
  `gx` float DEFAULT NULL,
  `gy` float DEFAULT NULL,
  `TreeID` int(11) NOT NULL,
  `Tag` char(10) DEFAULT NULL,
  `StemID` int(11) NOT NULL,
  `StemTag` varchar(32) DEFAULT NULL,
  `PrimaryStem` char(20) DEFAULT NULL,
  `CensusID` int(11) NOT NULL,
  `PlotCensusNumber` int(11) DEFAULT NULL,
  `DBH` float DEFAULT NULL,
  `HOM` float DEFAULT NULL,
  `ExactDate` date DEFAULT NULL,
  `ListOfTSM` varchar(256) DEFAULT NULL,
  `Status` varchar(15) DEFAULT NULL,
  PRIMARY KEY (`MeasureID`,`CensusID`),
  KEY `PlotID` (`PlotID`),
  KEY `Genus` (`Genus`(5)),
  KEY `SpeciesName` (`SpeciesName`(5)),
  KEY `SpeciesID` (`SpeciesID`),
  KEY `QuadratName` (`QuadratName`(4)),
  KEY `PlotCensusNumber` (`PlotCensusNumber`),
  KEY `DBH` (`DBH`),
  KEY `PrimaryStem` (`PrimaryStem`),
  KEY `ListOfTSM` (`ListOfTSM`),
  KEY `Status` (`Status`),
  KEY `ForDataEntry` (`TreeID`,`StemID`,`CensusID`),
  KEY `ForDataScreening` (`Tag`,`StemTag`,`PlotID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `Family`
--

CREATE TABLE IF NOT EXISTS `Family` (
  `FamilyID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Family` char(32) DEFAULT NULL,
  `ReferenceID` smallint(5) unsigned DEFAULT NULL,
  PRIMARY KEY (`FamilyID`),
  KEY `Ref84175` (`ReferenceID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=550 ;

-- --------------------------------------------------------

--
-- Table structure for table `Genus`
--

CREATE TABLE IF NOT EXISTS `Genus` (
  `GenusID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Genus` char(32) DEFAULT NULL,
  `ReferenceID` smallint(5) unsigned DEFAULT NULL,
  `Authority` char(32) DEFAULT NULL,
  `FamilyID` int(10) unsigned NOT NULL,
  PRIMARY KEY (`GenusID`),
  KEY `Ref2868` (`FamilyID`),
  KEY `Ref84176` (`ReferenceID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=21244 ;

-- --------------------------------------------------------

--
-- Table structure for table `LogMAttrHistory`
--

CREATE TABLE IF NOT EXISTS `LogMAttrHistory` (
  `LogMAttrHistoryID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `MeasureID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `TSMID` int(10) unsigned NOT NULL,
  `DateOfChange` date DEFAULT NULL,
  `DescriptionOfChange` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`LogMAttrHistoryID`),
  KEY `Ref21225` (`MeasureID`,`CensusID`,`TSMID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13754 ;

-- --------------------------------------------------------

--
-- Table structure for table `LogMAttrHistoryd`
--

CREATE TABLE IF NOT EXISTS `LogMAttrHistoryd` (
  `LogMAttrHistoryID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `MeasureID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `TSMID` int(10) unsigned NOT NULL,
  `DateOfChange` date DEFAULT NULL,
  `DescriptionOfChange` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`LogMAttrHistoryID`),
  KEY `Ref21225` (`MeasureID`,`CensusID`,`TSMID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

-- --------------------------------------------------------

--
-- Table structure for table `LogMeasurementHistory`
--

CREATE TABLE IF NOT EXISTS `LogMeasurementHistory` (
  `MeasureID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `MeasurementHistoryID` int(10) unsigned NOT NULL,
  `StemID` int(10) unsigned DEFAULT NULL,
  `TreeID` int(10) unsigned DEFAULT NULL,
  `DateOfChange` date NOT NULL,
  `DescriptionOfChange` varchar(128) DEFAULT NULL,
  `DBH` float DEFAULT NULL,
  `HOM` float DEFAULT NULL,
  `ExactDate` date DEFAULT NULL,
  PRIMARY KEY (`MeasureID`,`CensusID`,`MeasurementHistoryID`),
  KEY `Ref287` (`MeasureID`,`CensusID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `LogMeasurementHistoryd`
--

CREATE TABLE IF NOT EXISTS `LogMeasurementHistoryd` (
  `MeasureID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `MeasurementHistoryID` int(10) unsigned NOT NULL,
  `StemID` int(10) unsigned DEFAULT NULL,
  `TreeID` int(10) unsigned DEFAULT NULL,
  `DateOfChange` date NOT NULL,
  `DescriptionOfChange` varchar(128) DEFAULT NULL,
  `DBH` float DEFAULT NULL,
  `HOM` float DEFAULT NULL,
  `ExactDate` date DEFAULT NULL,
  PRIMARY KEY (`MeasureID`,`CensusID`,`MeasurementHistoryID`),
  KEY `Ref287` (`MeasureID`,`CensusID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `LogSpeciesInventory`
--

CREATE TABLE IF NOT EXISTS `LogSpeciesInventory` (
  `SpeciesInvHistID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `SpeciesInvID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `PlotID` int(10) unsigned NOT NULL,
  `SpeciesID` int(10) unsigned NOT NULL,
  `SubSpeciesID` int(10) unsigned DEFAULT NULL,
  `DateOfChange` date DEFAULT NULL,
  `DescriptionOfChange` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`SpeciesInvHistID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=47 ;

-- --------------------------------------------------------

--
-- Table structure for table `LogTreeAttrHistory`
--

CREATE TABLE IF NOT EXISTS `LogTreeAttrHistory` (
  `LogTAttrHistoryID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CensusID` int(10) unsigned NOT NULL,
  `TreeID` int(10) unsigned NOT NULL,
  `TSMID` int(10) unsigned NOT NULL,
  `DateOfChange` date DEFAULT NULL,
  `DescriptionOfChange` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`LogTAttrHistoryID`),
  KEY `Ref24226` (`CensusID`,`TreeID`,`TSMID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `LogTreeHistory`
--

CREATE TABLE IF NOT EXISTS `LogTreeHistory` (
  `TreeID` int(10) unsigned NOT NULL,
  `TreeHistoryID` int(10) unsigned NOT NULL,
  `ChangeCodeID` int(10) unsigned DEFAULT NULL,
  `ChangeDate` date DEFAULT NULL,
  `ChangeDescription` varchar(128) DEFAULT NULL,
  `QuadratID` int(10) unsigned DEFAULT NULL,
  `PlotID` int(10) unsigned DEFAULT NULL,
  `Tag` char(10) DEFAULT NULL,
  `X` float DEFAULT NULL,
  `Y` float DEFAULT NULL,
  `SpeciesID` int(10) unsigned DEFAULT NULL,
  `SubSpeciesID` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`TreeID`,`TreeHistoryID`),
  KEY `Ref186` (`TreeID`),
  KEY `Ref32221` (`ChangeCodeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `LogTreeHistoryd`
--

CREATE TABLE IF NOT EXISTS `LogTreeHistoryd` (
  `TreeID` int(10) unsigned NOT NULL,
  `TreeHistoryID` int(10) unsigned NOT NULL,
  `ChangeCodeID` int(10) unsigned DEFAULT NULL,
  `ChangeDate` date DEFAULT NULL,
  `ChangeDescription` varchar(128) DEFAULT NULL,
  `QuadratID` int(10) unsigned DEFAULT NULL,
  `PlotID` int(10) unsigned DEFAULT NULL,
  `Tag` char(10) DEFAULT NULL,
  `X` float DEFAULT NULL,
  `Y` float DEFAULT NULL,
  `SpeciesID` int(10) unsigned DEFAULT NULL,
  `SubSpeciesID` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`TreeID`,`TreeHistoryID`),
  KEY `Ref186` (`TreeID`),
  KEY `Ref32221` (`ChangeCodeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `Measurement`
--

CREATE TABLE IF NOT EXISTS `Measurement` (
  `MeasureID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `StemID` int(10) unsigned NOT NULL,
  `TreeID` int(10) unsigned NOT NULL,
  `DBH` float DEFAULT NULL,
  `HOM` float DEFAULT NULL,
  `PrimaryStem` varchar(20) DEFAULT NULL,
  `ExactDate` date DEFAULT NULL,
  PRIMARY KEY (`MeasureID`,`CensusID`),
  KEY `Ref549` (`CensusID`),
  KEY `Ref1951` (`StemID`,`TreeID`),
  KEY `TreeID` (`TreeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `MeasurementAttributes`
--

CREATE TABLE IF NOT EXISTS `MeasurementAttributes` (
  `MeasureID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `TSMID` int(10) unsigned NOT NULL,
  PRIMARY KEY (`MeasureID`,`CensusID`,`TSMID`),
  KEY `Ref252` (`MeasureID`,`CensusID`),
  KEY `Ref2053` (`TSMID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `Personnel`
--

CREATE TABLE IF NOT EXISTS `Personnel` (
  `PersonnelID` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `FirstName` varchar(32) DEFAULT NULL,
  `LastName` varchar(32) NOT NULL,
  PRIMARY KEY (`PersonnelID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=95 ;

-- --------------------------------------------------------

--
-- Table structure for table `Quadrat`
--

CREATE TABLE IF NOT EXISTS `Quadrat` (
  `QuadratID` int(10) unsigned NOT NULL,
  `PlotID` int(10) unsigned NOT NULL,
  `QuadratName` char(8) DEFAULT NULL,
  `StartX` float DEFAULT NULL,
  `StartY` float DEFAULT NULL,
  `DimX` float DEFAULT NULL,
  `DimY` float DEFAULT NULL,
  PRIMARY KEY (`QuadratID`,`PlotID`),
  KEY `Ref69` (`PlotID`),
  KEY `QuadratName` (`QuadratName`,`PlotID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `Reference`
--

CREATE TABLE IF NOT EXISTS `Reference` (
  `ReferenceID` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `PublicationTitle` varchar(64) DEFAULT NULL,
  `FullReference` varchar(256) DEFAULT NULL,
  `DateofPublication` date DEFAULT NULL,
  PRIMARY KEY (`ReferenceID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

-- --------------------------------------------------------

--
-- Table structure for table `RemeasAttribs`
--

CREATE TABLE IF NOT EXISTS `RemeasAttribs` (
  `RemeasureID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `TSMID` int(10) unsigned NOT NULL,
  PRIMARY KEY (`RemeasureID`,`CensusID`,`TSMID`),
  KEY `Ref2073` (`TSMID`),
  KEY `Ref2274` (`RemeasureID`,`CensusID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `Remeasurement`
--

CREATE TABLE IF NOT EXISTS `Remeasurement` (
  `RemeasureID` int(10) unsigned NOT NULL,
  `CensusID` int(10) unsigned NOT NULL,
  `StemID` int(10) unsigned NOT NULL,
  `TreeID` int(10) unsigned NOT NULL,
  `DBH` float DEFAULT NULL,
  `HOM` float DEFAULT NULL,
  `ExactDate` date DEFAULT NULL,
  PRIMARY KEY (`RemeasureID`,`CensusID`),
  KEY `Ref1957` (`StemID`,`TreeID`),
  KEY `Ref5106` (`CensusID`),
  KEY `RefTree57` (`TreeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `ReviewChange`
--

CREATE TABLE IF NOT EXISTS `ReviewChange` (
  `RID` int(4) unsigned NOT NULL,
  `TreeID` int(10) unsigned NOT NULL,
  `QuadratID` int(10) unsigned NOT NULL,
  `PlotID` int(10) unsigned NOT NULL,
  `FmSpeciesID` int(10) unsigned NOT NULL,
  `ToSpeciesID` int(10) unsigned NOT NULL,
  `ChangeCodeID` int(10) unsigned NOT NULL,
  `Tag` char(10) DEFAULT NULL,
  PRIMARY KEY (`RID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `ReviewNewSpecies`
--

CREATE TABLE IF NOT EXISTS `ReviewNewSpecies` (
  `SpeciesID` int(10) unsigned NOT NULL,
  `genusID` int(10) unsigned NOT NULL,
  `ReferenceID` smallint(5) unsigned DEFAULT NULL,
  `FullSpeciesName` char(128) DEFAULT NULL,
  `Authority` varchar(128) DEFAULT NULL,
  `IDLevel` char(8) DEFAULT NULL,
  `FieldFamily` char(32) DEFAULT NULL,
  `Description` varchar(128) DEFAULT NULL,
  `PublicationTitle` varchar(128) DEFAULT NULL,
  `FullReference` varchar(256) DEFAULT NULL,
  `DateOfPublication` date DEFAULT NULL,
  PRIMARY KEY (`SpeciesID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `RoleReference`
--

CREATE TABLE IF NOT EXISTS `RoleReference` (
  `RoleID` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `Description` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`RoleID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

-- --------------------------------------------------------

--
-- Table structure for table `Site`
--

CREATE TABLE IF NOT EXISTS `Site` (
  `PlotID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `PlotName` char(64) DEFAULT NULL,
  `LocationName` varchar(128) DEFAULT NULL,
  `CountryID` smallint(5) unsigned NOT NULL,
  `Latitude` float DEFAULT NULL,
  `Longitude` float DEFAULT NULL,
  `Elevation` float DEFAULT NULL,
  `ReferenceX` float DEFAULT NULL,
  `ReferenceY` float DEFAULT NULL,
  `SizeOfSite` char(32) DEFAULT NULL,
  `ShapeOfSite` char(32) DEFAULT NULL,
  `DescriptionOfSite` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`PlotID`),
  KEY `Ref87173` (`CountryID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=158 ;

-- --------------------------------------------------------

--
-- Table structure for table `Species`
--

CREATE TABLE IF NOT EXISTS `Species` (
  `SpeciesID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CurrentTaxonFlag` smallint(6) DEFAULT NULL,
  `ObsoleteTaxonFlag` smallint(6) DEFAULT NULL,
  `GenusID` int(10) unsigned NOT NULL,
  `ReferenceID` smallint(5) unsigned DEFAULT NULL,
  `SpeciesName` char(64) DEFAULT NULL,
  `Mnemonic` char(10) DEFAULT NULL,
  `Authority` varchar(128) DEFAULT NULL,
  `IDLevel` char(8) DEFAULT NULL,
  `FieldFamily` char(32) DEFAULT NULL,
  `Description` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`SpeciesID`),
  KEY `Ref26208` (`GenusID`),
  KEY `Ref84209` (`ReferenceID`),
  KEY `Mnemonic` (`Mnemonic`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1473 ;

-- --------------------------------------------------------

--
-- Table structure for table `SpeciesInventory`
--

CREATE TABLE IF NOT EXISTS `SpeciesInventory` (
  `SpeciesInvID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CensusID` int(10) unsigned NOT NULL,
  `PlotID` int(10) unsigned NOT NULL,
  `SpeciesID` int(10) unsigned NOT NULL,
  `SubSpeciesID` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`SpeciesInvID`),
  KEY `Ref92198` (`SpeciesID`),
  KEY `Ref93199` (`SubSpeciesID`),
  KEY `Ref5222` (`CensusID`),
  KEY `Ref642` (`PlotID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10226 ;

-- --------------------------------------------------------

--
-- Table structure for table `Specimen`
--

CREATE TABLE IF NOT EXISTS `Specimen` (
  `SpecimenID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `TreeID` int(10) unsigned NOT NULL,
  `Collector` char(64) DEFAULT NULL,
  `SpecimenNumber` int(10) unsigned DEFAULT NULL,
  `SpeciesID` int(10) unsigned NOT NULL,
  `SubSpeciesID` int(10) unsigned DEFAULT NULL,
  `Herbarium` char(32) DEFAULT NULL,
  `Voucher` smallint(5) unsigned DEFAULT NULL,
  `CollectionDate` date DEFAULT NULL,
  `DeterminedBy` char(64) DEFAULT NULL,
  `Description` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`SpecimenID`),
  KEY `Ref93194` (`SubSpeciesID`),
  KEY `Ref92196` (`SpeciesID`),
  KEY `Ref1171` (`TreeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `SqlLog`
--

CREATE TABLE IF NOT EXISTS `SqlLog` (
  `SqlID` int(4) NOT NULL DEFAULT '0',
  `ToTableName` varchar(23) DEFAULT NULL,
  `SqlStmt` varchar(16384) DEFAULT NULL,
  PRIMARY KEY (`SqlID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `StageSource`
--

CREATE TABLE IF NOT EXISTS `StageSource` (
  `ChangeID` int(10) unsigned NOT NULL,
  `SourceNo` int(10) unsigned NOT NULL,
  `SpeciesID` int(10) unsigned NOT NULL,
  PRIMARY KEY (`ChangeID`,`SourceNo`),
  KEY `Ref96202` (`ChangeID`),
  KEY `Ref92214` (`SpeciesID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `StageTarget`
--

CREATE TABLE IF NOT EXISTS `StageTarget` (
  `ChangeID` int(10) unsigned NOT NULL,
  `TargetNo` int(10) unsigned NOT NULL,
  `SpeciesID` int(10) unsigned NOT NULL,
  PRIMARY KEY (`ChangeID`,`TargetNo`),
  KEY `Ref96203` (`ChangeID`),
  KEY `Ref92215` (`SpeciesID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `StageTargetNew`
--

CREATE TABLE IF NOT EXISTS `StageTargetNew` (
  `ChangeID` int(10) unsigned NOT NULL,
  `TargetNo` int(10) unsigned NOT NULL,
  `SpeciesID` int(10) unsigned NOT NULL,
  `CurrentTaxonFlag` smallint(6) DEFAULT NULL,
  `ObsoleteTaxonFlag` smallint(6) DEFAULT NULL,
  `GenusID` int(10) unsigned NOT NULL,
  `ReferenceID` smallint(5) unsigned NOT NULL,
  `SpeciesName` char(64) DEFAULT NULL,
  `Mnemonic` char(10) DEFAULT NULL,
  `Authority` varchar(128) DEFAULT NULL,
  `IDLevel` char(8) DEFAULT NULL,
  `FieldFamily` char(32) DEFAULT NULL,
  `Description` char(64) DEFAULT NULL,
  PRIMARY KEY (`ChangeID`,`TargetNo`),
  KEY `Ref96223` (`ChangeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `StageTaxonomicChanges`
--

CREATE TABLE IF NOT EXISTS `StageTaxonomicChanges` (
  `ChangeID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ChangeCodeID` int(10) unsigned NOT NULL,
  `PersonnelID` smallint(5) unsigned NOT NULL,
  `ChangeDate` date DEFAULT NULL,
  `NumberOfSource` int(10) unsigned DEFAULT NULL,
  `NumberOfTarget` int(10) unsigned DEFAULT NULL,
  `NumberOfTargetNew` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`ChangeID`),
  KEY `Ref32216` (`ChangeCodeID`),
  KEY `Ref15224` (`PersonnelID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `Stem`
--

CREATE TABLE IF NOT EXISTS `Stem` (
  `StemID` int(10) unsigned NOT NULL,
  `TreeID` int(10) unsigned NOT NULL,
  `StemTag` varchar(32) DEFAULT NULL,
  `StemDescription` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`StemID`,`TreeID`),
  KEY `Ref150` (`TreeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `SubSpecies`
--

CREATE TABLE IF NOT EXISTS `SubSpecies` (
  `SubSpeciesID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `SpeciesID` int(10) unsigned NOT NULL,
  `CurrentTaxonFlag` smallint(6) DEFAULT NULL,
  `ObsoleteTaxonFlag` smallint(6) DEFAULT NULL,
  `SubSpeciesName` char(64) DEFAULT NULL,
  `Mnemonic` char(10) DEFAULT NULL,
  `Authority` varchar(128) DEFAULT NULL,
  `InfraSpecificLevel` char(32) DEFAULT NULL,
  PRIMARY KEY (`SubSpeciesID`),
  KEY `Ref92193` (`SpeciesID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;

-- --------------------------------------------------------

--
-- Table structure for table `TAX1temp`
--

CREATE TABLE IF NOT EXISTS `TAX1temp` (
  `SpeciesID` int(11) NOT NULL,
  `SubspeciesID` int(11) NOT NULL DEFAULT '0',
  `Family` char(32) DEFAULT NULL,
  `Genus` char(32) DEFAULT NULL,
  `Mnemonic` char(10) DEFAULT NULL,
  `SpeciesName` char(64) DEFAULT NULL,
  `SubspeciesName` char(64) DEFAULT NULL,
  `IDLevel` char(8) DEFAULT NULL,
  `Authority` char(124) DEFAULT NULL,
  `ListOfOldNames` varchar(255) DEFAULT NULL,
  `NumberOfHerbarium` int(11) DEFAULT NULL,
  `ListOfHerbarium` varchar(255) DEFAULT NULL,
  `Description` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`SpeciesID`,`SubspeciesID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `TAX2temp`
--

CREATE TABLE IF NOT EXISTS `TAX2temp` (
  `SpeciesID` int(11) NOT NULL,
  `ObsoleteSpeciesID` int(11) NOT NULL,
  `ObsoleteGenusName` char(32) DEFAULT NULL,
  `ObsoleteSpeciesName` char(64) DEFAULT NULL,
  `ObsoleteGenSpeName` char(128) DEFAULT NULL,
  `Description` char(128) DEFAULT NULL,
  `ChangeDate` date NOT NULL DEFAULT '0000-00-00',
  `Family` char(32) DEFAULT NULL,
  `Genus` char(32) DEFAULT NULL,
  `SpeciesName` char(64) DEFAULT NULL,
  `Authority` char(128) DEFAULT NULL,
  `IDLevel` char(8) DEFAULT NULL,
  PRIMARY KEY (`SpeciesID`,`ObsoleteSpeciesID`,`ChangeDate`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `TAX3temp`
--

CREATE TABLE IF NOT EXISTS `TAX3temp` (
  `PlotSpeciesID` int(11) NOT NULL AUTO_INCREMENT,
  `PlotID` int(11) NOT NULL,
  `SpeciesID` int(11) NOT NULL,
  `SubSpeciesID` int(11) DEFAULT NULL,
  PRIMARY KEY (`PlotSpeciesID`),
  KEY `TAX3Plot` (`PlotID`,`SpeciesID`,`SubSpeciesID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=17167 ;

-- --------------------------------------------------------

--
-- Table structure for table `Tree`
--

CREATE TABLE IF NOT EXISTS `Tree` (
  `TreeID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `QuadratID` int(10) unsigned NOT NULL,
  `PlotID` int(10) unsigned NOT NULL,
  `Tag` char(10) DEFAULT NULL,
  `x` float DEFAULT NULL,
  `y` float DEFAULT NULL,
  `SpeciesID` int(10) unsigned NOT NULL,
  `SubSpeciesID` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`TreeID`),
  KEY `Ref92217` (`SpeciesID`),
  KEY `Ref93219` (`SubSpeciesID`),
  KEY `Ref735` (`QuadratID`,`PlotID`),
  KEY `Tag` (`Tag`,`PlotID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=482149 ;

-- --------------------------------------------------------

--
-- Table structure for table `TreeAttributes`
--

CREATE TABLE IF NOT EXISTS `TreeAttributes` (
  `CensusID` int(10) unsigned NOT NULL,
  `TreeID` int(10) unsigned NOT NULL,
  `TSMID` int(10) unsigned NOT NULL,
  PRIMARY KEY (`CensusID`,`TreeID`,`TSMID`),
  KEY `Ref163` (`TreeID`),
  KEY `Ref2064` (`TSMID`),
  KEY `Ref5107` (`CensusID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `TreeTaxChange`
--

CREATE TABLE IF NOT EXISTS `TreeTaxChange` (
  `ChangeCodeID` int(10) unsigned NOT NULL,
  `Description` varchar(128) DEFAULT NULL,
  PRIMARY KEY (`ChangeCodeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Table structure for table `TSMAttributes`
--

CREATE TABLE IF NOT EXISTS `TSMAttributes` (
  `TSMID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `TSMCode` char(10) NOT NULL,
  `Description` varchar(128) NOT NULL,
  PRIMARY KEY (`TSMID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=60 ;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `Census`
--
ALTER TABLE `Census`
  ADD CONSTRAINT `Census_ibfk_1` FOREIGN KEY (`PlotID`) REFERENCES `Site` (`PlotID`),
  ADD CONSTRAINT `Census_ibfk_2` FOREIGN KEY (`PlotID`) REFERENCES `Site` (`PlotID`);

--
-- Constraints for table `CensusQuadrat`
--
ALTER TABLE `CensusQuadrat`
  ADD CONSTRAINT `CensusQuadrat_ibfk_1` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `CensusQuadrat_ibfk_2` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `CensusQuadrat_ibfk_3` FOREIGN KEY (`QuadratID`, `PlotID`) REFERENCES `Quadrat` (`QuadratID`, `PlotID`),
  ADD CONSTRAINT `CensusQuadrat_ibfk_4` FOREIGN KEY (`QuadratID`, `PlotID`) REFERENCES `Quadrat` (`QuadratID`, `PlotID`);

--
-- Constraints for table `CurrentObsolete`
--
ALTER TABLE `CurrentObsolete`
  ADD CONSTRAINT `CurrentObsolete_ibfk_1` FOREIGN KEY (`ObsoleteSpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `CurrentObsolete_ibfk_2` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `CurrentObsolete_ibfk_3` FOREIGN KEY (`ObsoleteSpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `CurrentObsolete_ibfk_4` FOREIGN KEY (`ChangeCodeID`) REFERENCES `TreeTaxChange` (`ChangeCodeID`),
  ADD CONSTRAINT `CurrentObsolete_ibfk_5` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `CurrentObsolete_ibfk_6` FOREIGN KEY (`ChangeCodeID`) REFERENCES `TreeTaxChange` (`ChangeCodeID`);

--
-- Constraints for table `DataCollection`
--
ALTER TABLE `DataCollection`
  ADD CONSTRAINT `DataCollection_ibfk_1` FOREIGN KEY (`RoleID`) REFERENCES `RoleReference` (`RoleID`),
  ADD CONSTRAINT `DataCollection_ibfk_2` FOREIGN KEY (`CensusID`, `QuadratID`, `PlotID`) REFERENCES `CensusQuadrat` (`CensusID`, `QuadratID`, `PlotID`),
  ADD CONSTRAINT `DataCollection_ibfk_3` FOREIGN KEY (`PersonnelID`) REFERENCES `Personnel` (`PersonnelID`),
  ADD CONSTRAINT `DataCollection_ibfk_4` FOREIGN KEY (`RoleID`) REFERENCES `RoleReference` (`RoleID`),
  ADD CONSTRAINT `DataCollection_ibfk_5` FOREIGN KEY (`CensusID`, `QuadratID`, `PlotID`) REFERENCES `CensusQuadrat` (`CensusID`, `QuadratID`, `PlotID`),
  ADD CONSTRAINT `DataCollection_ibfk_6` FOREIGN KEY (`PersonnelID`) REFERENCES `Personnel` (`PersonnelID`);

--
-- Constraints for table `DataEntry`
--
ALTER TABLE `DataEntry`
  ADD CONSTRAINT `DataEntry_ibfk_1` FOREIGN KEY (`CensusID`, `QuadratID`, `PlotID`) REFERENCES `CensusQuadrat` (`CensusID`, `QuadratID`, `PlotID`),
  ADD CONSTRAINT `DataEntry_ibfk_2` FOREIGN KEY (`CensusID`, `QuadratID`, `PlotID`) REFERENCES `CensusQuadrat` (`CensusID`, `QuadratID`, `PlotID`),
  ADD CONSTRAINT `DataEntry_ibfk_3` FOREIGN KEY (`PersonnelID`) REFERENCES `Personnel` (`PersonnelID`);

--
-- Constraints for table `Family`
--
ALTER TABLE `Family`
  ADD CONSTRAINT `Family_ibfk_1` FOREIGN KEY (`ReferenceID`) REFERENCES `Reference` (`ReferenceID`);

--
-- Constraints for table `Genus`
--
ALTER TABLE `Genus`
  ADD CONSTRAINT `Genus_ibfk_1` FOREIGN KEY (`FamilyID`) REFERENCES `Family` (`FamilyID`),
  ADD CONSTRAINT `Genus_ibfk_2` FOREIGN KEY (`FamilyID`) REFERENCES `Family` (`FamilyID`),
  ADD CONSTRAINT `Genus_ibfk_3` FOREIGN KEY (`ReferenceID`) REFERENCES `Reference` (`ReferenceID`),
  ADD CONSTRAINT `Genus_ibfk_4` FOREIGN KEY (`ReferenceID`) REFERENCES `Reference` (`ReferenceID`);

--
-- Constraints for table `LogMAttrHistory`
--
ALTER TABLE `LogMAttrHistory`
  ADD CONSTRAINT `LogMAttrHistory_ibfk_1` FOREIGN KEY (`MeasureID`, `CensusID`, `TSMID`) REFERENCES `MeasurementAttributes` (`MeasureID`, `CensusID`, `TSMID`);

--
-- Constraints for table `LogMeasurementHistory`
--
ALTER TABLE `LogMeasurementHistory`
  ADD CONSTRAINT `LogMeasurementHistory_ibfk_1` FOREIGN KEY (`MeasureID`, `CensusID`) REFERENCES `Measurement` (`MeasureID`, `CensusID`);

--
-- Constraints for table `LogTreeAttrHistory`
--
ALTER TABLE `LogTreeAttrHistory`
  ADD CONSTRAINT `LogTreeAttrHistory_ibfk_1` FOREIGN KEY (`CensusID`, `TreeID`, `TSMID`) REFERENCES `TreeAttributes` (`CensusID`, `TreeID`, `TSMID`);

--
-- Constraints for table `LogTreeHistory`
--
ALTER TABLE `LogTreeHistory`
  ADD CONSTRAINT `LogTreeHistory_ibfk_1` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`);

--
-- Constraints for table `Measurement`
--
ALTER TABLE `Measurement`
  ADD CONSTRAINT `Measurement_ibfk_1` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `Measurement_ibfk_2` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `Measurement_ibfk_3` FOREIGN KEY (`StemID`, `TreeID`) REFERENCES `Stem` (`StemID`, `TreeID`),
  ADD CONSTRAINT `Measurement_ibfk_4` FOREIGN KEY (`StemID`, `TreeID`) REFERENCES `Stem` (`StemID`, `TreeID`);

--
-- Constraints for table `MeasurementAttributes`
--
ALTER TABLE `MeasurementAttributes`
  ADD CONSTRAINT `MeasurementAttributes_ibfk_1` FOREIGN KEY (`MeasureID`, `CensusID`) REFERENCES `Measurement` (`MeasureID`, `CensusID`),
  ADD CONSTRAINT `MeasurementAttributes_ibfk_2` FOREIGN KEY (`MeasureID`, `CensusID`) REFERENCES `Measurement` (`MeasureID`, `CensusID`),
  ADD CONSTRAINT `MeasurementAttributes_ibfk_3` FOREIGN KEY (`TSMID`) REFERENCES `TSMAttributes` (`TSMID`);

--
-- Constraints for table `Quadrat`
--
ALTER TABLE `Quadrat`
  ADD CONSTRAINT `Quadrat_ibfk_1` FOREIGN KEY (`PlotID`) REFERENCES `Site` (`PlotID`),
  ADD CONSTRAINT `Quadrat_ibfk_2` FOREIGN KEY (`PlotID`) REFERENCES `Site` (`PlotID`);

--
-- Constraints for table `RemeasAttribs`
--
ALTER TABLE `RemeasAttribs`
  ADD CONSTRAINT `RemeasAttribs_ibfk_1` FOREIGN KEY (`RemeasureID`, `CensusID`) REFERENCES `Remeasurement` (`RemeasureID`, `CensusID`),
  ADD CONSTRAINT `RemeasAttribs_ibfk_2` FOREIGN KEY (`TSMID`) REFERENCES `TSMAttributes` (`TSMID`),
  ADD CONSTRAINT `RemeasAttribs_ibfk_3` FOREIGN KEY (`RemeasureID`, `CensusID`) REFERENCES `Remeasurement` (`RemeasureID`, `CensusID`),
  ADD CONSTRAINT `RemeasAttribs_ibfk_4` FOREIGN KEY (`TSMID`) REFERENCES `TSMAttributes` (`TSMID`);

--
-- Constraints for table `Remeasurement`
--
ALTER TABLE `Remeasurement`
  ADD CONSTRAINT `Remeasurement_ibfk_1` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `Remeasurement_ibfk_2` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`),
  ADD CONSTRAINT `Remeasurement_ibfk_3` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `Remeasurement_ibfk_4` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`);

--
-- Constraints for table `Site`
--
ALTER TABLE `Site`
  ADD CONSTRAINT `Site_ibfk_1` FOREIGN KEY (`CountryID`) REFERENCES `Country` (`CountryID`),
  ADD CONSTRAINT `Site_ibfk_2` FOREIGN KEY (`CountryID`) REFERENCES `Country` (`CountryID`);

--
-- Constraints for table `Species`
--
ALTER TABLE `Species`
  ADD CONSTRAINT `Species_ibfk_1` FOREIGN KEY (`GenusID`) REFERENCES `Genus` (`GenusID`),
  ADD CONSTRAINT `Species_ibfk_2` FOREIGN KEY (`GenusID`) REFERENCES `Genus` (`GenusID`);

--
-- Constraints for table `SpeciesInventory`
--
ALTER TABLE `SpeciesInventory`
  ADD CONSTRAINT `SpeciesInventory_ibfk_1` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `SpeciesInventory_ibfk_2` FOREIGN KEY (`PlotID`) REFERENCES `Site` (`PlotID`),
  ADD CONSTRAINT `SpeciesInventory_ibfk_3` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `SpeciesInventory_ibfk_4` FOREIGN KEY (`SubSpeciesID`) REFERENCES `SubSpecies` (`SubSpeciesID`),
  ADD CONSTRAINT `SpeciesInventory_ibfk_5` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `SpeciesInventory_ibfk_6` FOREIGN KEY (`PlotID`) REFERENCES `Site` (`PlotID`),
  ADD CONSTRAINT `SpeciesInventory_ibfk_7` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `SpeciesInventory_ibfk_8` FOREIGN KEY (`SubSpeciesID`) REFERENCES `SubSpecies` (`SubSpeciesID`);

--
-- Constraints for table `Specimen`
--
ALTER TABLE `Specimen`
  ADD CONSTRAINT `Specimen_ibfk_1` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `Specimen_ibfk_2` FOREIGN KEY (`SubSpeciesID`) REFERENCES `SubSpecies` (`SubSpeciesID`),
  ADD CONSTRAINT `Specimen_ibfk_3` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`),
  ADD CONSTRAINT `Specimen_ibfk_4` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `Specimen_ibfk_5` FOREIGN KEY (`SubSpeciesID`) REFERENCES `SubSpecies` (`SubSpeciesID`),
  ADD CONSTRAINT `Specimen_ibfk_6` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`);

--
-- Constraints for table `StageSource`
--
ALTER TABLE `StageSource`
  ADD CONSTRAINT `StageSource_ibfk_1` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `StageSource_ibfk_2` FOREIGN KEY (`ChangeID`) REFERENCES `StageTaxonomicChanges` (`ChangeID`);

--
-- Constraints for table `StageTarget`
--
ALTER TABLE `StageTarget`
  ADD CONSTRAINT `StageTarget_ibfk_1` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `StageTarget_ibfk_2` FOREIGN KEY (`ChangeID`) REFERENCES `StageTaxonomicChanges` (`ChangeID`);

--
-- Constraints for table `StageTargetNew`
--
ALTER TABLE `StageTargetNew`
  ADD CONSTRAINT `StageTargetNew_ibfk_1` FOREIGN KEY (`ChangeID`) REFERENCES `StageTaxonomicChanges` (`ChangeID`);

--
-- Constraints for table `StageTaxonomicChanges`
--
ALTER TABLE `StageTaxonomicChanges`
  ADD CONSTRAINT `StageTaxonomicChanges_ibfk_1` FOREIGN KEY (`PersonnelID`) REFERENCES `Personnel` (`PersonnelID`),
  ADD CONSTRAINT `StageTaxonomicChanges_ibfk_2` FOREIGN KEY (`ChangeCodeID`) REFERENCES `TreeTaxChange` (`ChangeCodeID`);

--
-- Constraints for table `Stem`
--
ALTER TABLE `Stem`
  ADD CONSTRAINT `Stem_ibfk_1` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`),
  ADD CONSTRAINT `Stem_ibfk_2` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`);

--
-- Constraints for table `SubSpecies`
--
ALTER TABLE `SubSpecies`
  ADD CONSTRAINT `SubSpecies_ibfk_1` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `SubSpecies_ibfk_2` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`);

--
-- Constraints for table `Tree`
--
ALTER TABLE `Tree`
  ADD CONSTRAINT `Tree_ibfk_1` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `Tree_ibfk_2` FOREIGN KEY (`QuadratID`, `PlotID`) REFERENCES `Quadrat` (`QuadratID`, `PlotID`),
  ADD CONSTRAINT `Tree_ibfk_3` FOREIGN KEY (`SubSpeciesID`) REFERENCES `SubSpecies` (`SubSpeciesID`),
  ADD CONSTRAINT `Tree_ibfk_4` FOREIGN KEY (`QuadratID`, `PlotID`) REFERENCES `Quadrat` (`QuadratID`, `PlotID`),
  ADD CONSTRAINT `Tree_ibfk_5` FOREIGN KEY (`SpeciesID`) REFERENCES `Species` (`SpeciesID`),
  ADD CONSTRAINT `Tree_ibfk_6` FOREIGN KEY (`SubSpeciesID`) REFERENCES `SubSpecies` (`SubSpeciesID`);

--
-- Constraints for table `TreeAttributes`
--
ALTER TABLE `TreeAttributes`
  ADD CONSTRAINT `TreeAttributes_ibfk_1` FOREIGN KEY (`TSMID`) REFERENCES `TSMAttributes` (`TSMID`),
  ADD CONSTRAINT `TreeAttributes_ibfk_2` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `TreeAttributes_ibfk_3` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`),
  ADD CONSTRAINT `TreeAttributes_ibfk_4` FOREIGN KEY (`CensusID`) REFERENCES `Census` (`CensusID`),
  ADD CONSTRAINT `TreeAttributes_ibfk_5` FOREIGN KEY (`TreeID`) REFERENCES `Tree` (`TreeID`),
  ADD CONSTRAINT `TreeAttributes_ibfk_6` FOREIGN KEY (`TSMID`) REFERENCES `TSMAttributes` (`TSMID`);

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
