-- MySQL Script generated by MySQL Workbench
-- Mon 29 Dec 2014 03:22:32 PM EET
-- Model: New Model    Version: 1.0
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------

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

CREATE TABLE IF NOT EXISTS `storedTagDataT` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `nodeTypeId` INT UNSIGNED NOT NULL,
  `added` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
  `changed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  INDEX `fk_storedTagDataT_nodeTypeT1_idx` (`nodeTypeId` ASC),
  CONSTRAINT `fk_storedTagDataT_nodeTypeT1`
    FOREIGN KEY (`nodeTypeId`)
    REFERENCES `nodeTypeT` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


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

CREATE TABLE IF NOT EXISTS `storedTagDataStreetT` (
  `id` VARCHAR(10) NOT NULL,
  `name_ukr` VARCHAR(100) NULL,
  `name_rus` VARCHAR(100) NULL,
  `name_eng` VARCHAR(100) NULL,
  `external_id` INT UNSIGNED NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_storedTagDataStreetT_storedTagDataT1_idx` (`external_id` ASC),
  CONSTRAINT `fk_storedTagDataStreetT_storedTagDataT1`
    FOREIGN KEY (`external_id`)
    REFERENCES `storedTagDataT` (`id`)
    ON DELETE SET NULL
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


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

CREATE TABLE IF NOT EXISTS `storedTagDataTL` (
  `id` INT UNSIGNED NOT NULL,
  `languageId` CHAR(3) NOT NULL,
  `name` VARCHAR(255) NOT NULL,
  `prefix` VARCHAR(255) NOT NULL DEFAULT '',
  `suffix` VARCHAR(255) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`, `languageId`),
  INDEX `fk_storedTagDataTL_languageT1_idx` (`languageId` ASC),
  INDEX `idx_storedtagdatat_name` (`name` ASC),
  CONSTRAINT `fk_storedTagDataTL_storedTagDataT1`
    FOREIGN KEY (`id`)
    REFERENCES `storedTagDataT` (`id`)
    ON DELETE CASCADE
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_storedTagDataTL_languageT1`
    FOREIGN KEY (`languageId`)
    REFERENCES `languageT` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


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

CREATE TABLE IF NOT EXISTS `tmpStreetDataT` (
  `id` VARCHAR(10) NOT NULL,
  `name_ukr` VARCHAR(100) NULL,
  `name_rus` VARCHAR(100) NULL,
  `name_eng` VARCHAR(100) NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


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