text: -- MySQL Script generated by MySQL Workbench
  -- Thu Dec  7 12:00:30 2017
  -- Model: New Model    Version: 1.0
  -- MySQL Workbench Forward Engineering
  
  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';
  
  -- -----------------------------------------------------
  -- Schema hydroclass
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `hydroclass` DEFAULT CHARACTER SET utf8 ;
  USE `hydroclass` ;
  
  -- -----------------------------------------------------
  -- Table `hydroclass`.`Sites`
  -- -----------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS `hydroclass`.`Sites` (
    `SiteID` INT(11) NOT NULL AUTO_INCREMENT,
    `SiteCode` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `Sitename` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `Latitude` DOUBLE NOT NULL,
    `Longitude` DOUBLE NOT NULL,
    `Elevation` DOUBLE NOT NULL,
    `ElevationDatum` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `State` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `County` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `Comments` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `SiteType` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    PRIMARY KEY (`SiteID`))
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8
  COLLATE = utf8_unicode_ci;
  
  -- -----------------------------------------------------
  -- Table `hydroclass`.`variables`
  -- -----------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS `hydroclass`.`variables` (
    `VariableID` INT(11) NOT NULL AUTO_INCREMENT,
    `VariableCode` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `VariableName` VARCHAR(225) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `VariableType` VARCHAR(225) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `VariableUnitesID` INT NOT NULL,
    `GeneralCategory` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    PRIMARY KEY (`VariableID`))
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8
  COLLATE = utf8_unicode_ci;
  
  -- -----------------------------------------------------
  -- Table `hydroclass`.`datavalues`
  -- -----------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS `hydroclass`.`datavalues` (
    `ValueID` INT(11) NOT NULL AUTO_INCREMENT,
    `DataValue` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `UTCOffset` DOUBLE NOT NULL,
    `DateTime` INT NOT NULL,
    `Sites_SiteID2` INT(11) NOT NULL,
    `variables_VariableID` INT(11) NOT NULL,
    `MethodID` INT NOT NULL,
    `SourceID` INT NOT NULL,
    `UnitID` VARCHAR(45) NOT NULL,
    INDEX `fk_datavalues_Sites1_idx` (`Sites_SiteID2` ASC),
    INDEX `fk_datavalues_variables1_idx` (`variables_VariableID` ASC),
    PRIMARY KEY (`ValueID`),
    CONSTRAINT `fk_datavalues_Sites1`
      FOREIGN KEY (`Sites_SiteID2`)
      REFERENCES `hydroclass`.`Sites` (`SiteID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_datavalues_variables1`
      FOREIGN KEY (`variables_VariableID`)
      REFERENCES `hydroclass`.`variables` (`VariableID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8
  COLLATE = utf8_unicode_ci;
  
  
  -- -----------------------------------------------------
  -- Table `hydroclass`.`Method`
  -- -----------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS `hydroclass`.`Method` (
    `MethodID` INT(11) NOT NULL AUTO_INCREMENT,
    `MethodDescription` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `MethodLink` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL,
    `variables_VariableID` INT(11) NOT NULL,
    PRIMARY KEY (`MethodID`),
    INDEX `fk_Method_variables1_idx` (`variables_VariableID` ASC),
    CONSTRAINT `fk_Method_variables1`
      FOREIGN KEY (`variables_VariableID`)
      REFERENCES `hydroclass`.`variables` (`VariableID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8
  COLLATE = utf8_unicode_ci;
  
  -- -----------------------------------------------------
  -- Table `hydroclass`.`Units`
  -- -----------------------------------------------------
  
  CREATE TABLE IF NOT EXISTS `hydroclass`.`Units` (
    `UnitID` INT NOT NULL AUTO_INCREMENT,
    `UnitName` VARCHAR(45) NOT NULL,
    `UnitType` VARCHAR(45) NOT NULL,
    `UnitAbbreviation` VARCHAR(45) NOT NULL,
    `variables_VariableID` INT(11) NOT NULL,
    PRIMARY KEY (`UnitID`),
    INDEX `fk_VaribaleUnit_variables1_idx` (`variables_VariableID` ASC),
    CONSTRAINT `fk_VaribaleUnit_variables1`
      FOREIGN KEY (`variables_VariableID`)
      REFERENCES `hydroclass`.`variables` (`VariableID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  -- -----------------------------------------------------
  -- Table `hydroclass`.`Source`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `hydroclass`.`Source` ;
  
  CREATE TABLE IF NOT EXISTS `hydroclass`.`Source` (
    `SourceID` INT NOT NULL AUTO_INCREMENT,
    `Organization` VARCHAR(45) NOT NULL,
    `SourceDescription` VARCHAR(45) NOT NULL,
    `SourceLink` VARCHAR(225) NOT NULL,
    `ContactName` VARCHAR(45) NOT NULL,
    `Phone` VARCHAR(45) NOT NULL,
    `Email` VARCHAR(45) NOT NULL,
    `Address` VARCHAR(45) NOT NULL,
    `City` VARCHAR(45) NOT NULL,
    `State` VARCHAR(45) NOT NULL,
    `ZipCode` INT NOT NULL,
    `variables_VariableID` INT(11) NOT NULL,
    PRIMARY KEY (`SourceID`),
    INDEX `fk_Source_variables1_idx` (`variables_VariableID` ASC),
    CONSTRAINT `fk_Source_variables1`
      FOREIGN KEY (`variables_VariableID`)
      REFERENCES `hydroclass`.`variables` (`VariableID`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  INSERT INTO `units` (`UnitID`,`UnitName`,`UnitType`,`UnitAbbreviation`,`variables_VariableID`) VALUES (1,'L/m','FlowRate','L/m',1);
  INSERT INTO `units` (`UnitID`,`UnitName`,`UnitType`,`UnitAbbreviation`,`variables_VariableID`) VALUES (2,'ml','Volume','ml',1);
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  