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


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

CREATE  TABLE IF NOT EXISTS `cel_images` (
  `ci_id_image` BIGINT(20) NOT NULL AUTO_INCREMENT ,
  `ci_ordre` BIGINT(20) NOT NULL ,
  `ci_ce_utilisateur` VARCHAR(60) NOT NULL ,
  `ci_publiable_eflore` TINYINT(1) NOT NULL ,
  `ci_note_image` TINYINT(5) NOT NULL DEFAULT '-1' ,
  `ci_meta_height` INT(11) NOT NULL ,
  `ci_meta_width` INT(11) NOT NULL ,
  `ci_meta_make` VARCHAR(20) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_model` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_x_resolution` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_y_resolution` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_date_time` VARCHAR(30) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_date` DATE NULL DEFAULT NULL ,
  `ci_meta_date_ajout` DATETIME NOT NULL ,
  `ci_meta_gps` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_user_comment` LONGTEXT CHARACTER SET 'ascii' NULL DEFAULT NULL ,
  `ci_meta_comment` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_mots_cles` VARCHAR(800) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_exposure_time` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_f_number` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_exif_version` INT(11) NULL DEFAULT NULL ,
  `ci_meta_exif_compressed_bits_per_pixel` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_shutter_speed_value` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_aperture_value` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_exposure_bias_value` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_max_aperture_value` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_metering_mode` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_light_source` VARCHAR(2) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_flash` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_focal_length` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_flash_pix_version` INT(10) NULL DEFAULT NULL ,
  `ci_meta_exif_color_space` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_interoperability_offset` INT(10) NULL DEFAULT NULL ,
  `ci_meta_exif_focal_plane_x_resolution` VARCHAR(20) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_focal_plane_y_resolution` VARCHAR(20) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_focal_plane_resolution_unit` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_sensing_method` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_file_source` TEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_custom_rendered` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_exposure_mode` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_white_balance` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_digital_zoom_ratio` VARCHAR(10) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_exif_scene_capture_type` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_gain_control` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_contrast` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_saturation` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_sharpness` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_subject_distance_range` INT(5) NULL DEFAULT NULL ,
  `ci_meta_exif_autres` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_category` VARCHAR(200) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_mots_cles` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_by_line` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_by_line_title` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_city` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_sub_location` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_province_state` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_country_primary_location_code` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_country_name` VARCHAR(200) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_headline` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_credit` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_copyright_notice` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_contact` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_meta_iptc_autres` LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_nom_original` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `ci_md5` VARCHAR(32) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  PRIMARY KEY (`ci_id_image`) ,
  INDEX `ci_id_image` (`ci_id_image` ASC, `ci_ordre` ASC, `ci_ce_utilisateur` ASC) ,
  INDEX `ci_ce_utilisateur` (`ci_ce_utilisateur` ASC) )
ENGINE = MyISAM
AUTO_INCREMENT = 51091
DEFAULT CHARACTER SET = utf8;


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

CREATE  TABLE IF NOT EXISTS `locations` (
  `name` VARCHAR(50) NOT NULL ,
  `maj_name` VARCHAR(50) NOT NULL ,
  `code` VARCHAR(3) NOT NULL DEFAULT '0' ,
  `insee_code` VARCHAR(5) NOT NULL DEFAULT '0' ,
  `sector` VARCHAR(3) NOT NULL ,
  `x_utm` VARCHAR(10) NOT NULL DEFAULT '0' ,
  `y_utm` VARCHAR(10) NOT NULL DEFAULT '0' ,
  `wgs84_latitude` DOUBLE NOT NULL ,
  `wgs84_longitude` DOUBLE NOT NULL ,
  `update_date` DATETIME NOT NULL ,
  PRIMARY KEY (`name`, `code`) ,
  INDEX `MAJ` (`maj_name` ASC, `code` ASC) ,
  INDEX `sector` (`sector` ASC, `x_utm` ASC, `y_utm` ASC) )
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8;


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

CREATE  TABLE IF NOT EXISTS `cel_inventory` (
  `id` BIGINT(20) NOT NULL AUTO_INCREMENT ,
  `identifiant` VARCHAR(128) NOT NULL ,
  `prenom_utilisateur` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Prénom de l\'utilisateur ayant saisi l\'observation.' ,
  `nom_utilisateur` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Nom de l\'utilisateur ayant saisi l\'observation.' ,
  `ordre` BIGINT(20) NOT NULL ,
  `nom_sel` VARCHAR(255) NOT NULL ,
  `num_nom_sel` INT(11) NOT NULL ,
  `nom_ret` VARCHAR(255) NOT NULL ,
  `num_nom_ret` INT(11) NOT NULL ,
  `num_taxon` INT(11) NOT NULL ,
  `famille` VARCHAR(255) NOT NULL ,
  `nom_referentiel` varchar(25) NOT NULL DEFAULT 'bdnff:4.02',
  `location` VARCHAR(50) NOT NULL ,
  `id_location` VARCHAR(10) NOT NULL ,
  `date_observation` DATETIME NOT NULL ,
  `lieudit` VARCHAR(255) NOT NULL ,
  `station` VARCHAR(255) NOT NULL ,
  `milieu` VARCHAR(255) NOT NULL ,
  `commentaire` VARCHAR(1024) NOT NULL ,
  `transmission` TINYINT(4) NOT NULL ,
  `date_creation` DATETIME NOT NULL ,
  `date_modification` DATETIME NOT NULL ,
  `date_transmission` DATETIME NOT NULL ,
  `mots_cles` LONGTEXT NOT NULL ,
  `mots_cles_texte` TEXT NULL DEFAULT NULL ,
  `coord_x` VARCHAR(50) NOT NULL ,
  `coord_y` VARCHAR(50) NOT NULL ,
  `ref_geo` VARCHAR(25) NOT NULL ,
  PRIMARY KEY (`id`) ,
  UNIQUE INDEX `identifiant_ordre` (`identifiant` ASC, `ordre` ASC) ,
  INDEX `identifiant_date_creation` (`identifiant` ASC, `date_creation` ASC) ,
  INDEX `id_location` (`id_location` ASC) ,
  INDEX `location` (`location` ASC) ,
  INDEX `date_observation` (`date_observation` ASC) ,
  INDEX `nom_ret` (`nom_ret` ASC) ,
  INDEX `identifiant` (`identifiant` ASC) ,
  INDEX `coordonnees` (`coord_x` ASC, `coord_y` ASC) )
ENGINE = MyISAM
AUTO_INCREMENT = 426426
DEFAULT CHARACTER SET = utf8;


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

CREATE  TABLE IF NOT EXISTS `cel_mots_cles_images` (
  `cmc_mot_cle` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_bg` INT(10) NOT NULL ,
  `cmc_bd` INT(10) NOT NULL ,
  `cmc_id_mot_cle_general` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_id_mot_cle_utilisateur` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_id_proprietaire` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_id_parent` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_niveau` INT(10) NOT NULL ,
  PRIMARY KEY (`cmc_id_mot_cle_utilisateur`, `cmc_id_proprietaire`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;


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

CREATE  TABLE IF NOT EXISTS `cel_mots_cles_obs` (
  `cmc_mot_cle` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_bg` INT(20) NOT NULL ,
  `cmc_bd` INT(20) NOT NULL ,
  `cmc_id_mot_cle_general` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_id_mot_cle_utilisateur` VARCHAR(128) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_id_proprietaire` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_id_parent` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL ,
  `cmc_niveau` INT(11) NOT NULL ,
  PRIMARY KEY (`cmc_id_mot_cle_utilisateur`, `cmc_id_proprietaire`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci
COMMENT = 'Table des mots clés, à utiliser avec des transactions !' 
ROW_FORMAT = COMPACT;


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

CREATE  TABLE IF NOT EXISTS `cel_obs_images` (
  `coi_ce_image` INT(11) NOT NULL ,
  `coi_ce_utilisateur` VARCHAR(100) CHARACTER SET 'utf8' NOT NULL ,
  `coi_ce_observation` INT(11) NOT NULL ,
  `coi_date_liaison` DATETIME NOT NULL ,
  PRIMARY KEY (`coi_ce_image`, `coi_ce_observation`) ,
  INDEX `coi_ce_utilisateur` (`coi_ce_utilisateur` ASC) ,
  INDEX `coi_ce_observation` (`coi_ce_observation` ASC) ,
  INDEX `coi_ce_image` (`coi_ce_image` ASC) )
ENGINE = MyISAM
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;



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