1267 |
jpm |
1 |
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
|
|
2 |
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
1376 |
raphael |
3 |
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
|
692 |
gduche |
4 |
|
1376 |
raphael |
5 |
|
1267 |
jpm |
6 |
-- -----------------------------------------------------
|
|
|
7 |
-- Table `del_utilisateur_infos`
|
|
|
8 |
-- -----------------------------------------------------
|
|
|
9 |
DROP TABLE IF EXISTS `del_utilisateur_infos` ;
|
692 |
gduche |
10 |
|
1870 |
jpm |
11 |
CREATE TABLE IF NOT EXISTS `del_utilisateur_infos` (
|
|
|
12 |
`id_utilisateur` INT(11) NOT NULL,
|
|
|
13 |
`admin` TINYINT(1) NULL,
|
|
|
14 |
`preferences` LONGTEXT NULL,
|
|
|
15 |
`date_premiere_utilisation` DATETIME NULL,
|
2061 |
aurelien |
16 |
`date_derniere_consultation_evenements` DATETIME NOT NULL,
|
1870 |
jpm |
17 |
PRIMARY KEY (`id_utilisateur`))
|
1267 |
jpm |
18 |
ENGINE = MyISAM;
|
692 |
gduche |
19 |
|
|
|
20 |
|
1267 |
jpm |
21 |
-- -----------------------------------------------------
|
|
|
22 |
-- Table `del_utilisateur`
|
|
|
23 |
-- -----------------------------------------------------
|
|
|
24 |
DROP TABLE IF EXISTS `del_utilisateur` ;
|
692 |
gduche |
25 |
|
1870 |
jpm |
26 |
CREATE TABLE IF NOT EXISTS `del_utilisateur` (
|
|
|
27 |
`id_utilisateur` INT NOT NULL AUTO_INCREMENT COMMENT 'Type varchar pour éviter problème de jointure.',
|
|
|
28 |
`prenom` VARCHAR(255) NOT NULL,
|
|
|
29 |
`nom` VARCHAR(255) NOT NULL,
|
|
|
30 |
`courriel` VARCHAR(255) NOT NULL,
|
|
|
31 |
`mot_de_passe` VARCHAR(45) NULL DEFAULT NULL,
|
|
|
32 |
PRIMARY KEY (`id_utilisateur`))
|
1267 |
jpm |
33 |
ENGINE = MyISAM
|
|
|
34 |
DEFAULT CHARACTER SET = utf8
|
|
|
35 |
COLLATE = utf8_general_ci;
|
692 |
gduche |
36 |
|
|
|
37 |
|
1267 |
jpm |
38 |
-- -----------------------------------------------------
|
1870 |
jpm |
39 |
-- Table `del_observation`
|
1267 |
jpm |
40 |
-- -----------------------------------------------------
|
1870 |
jpm |
41 |
DROP TABLE IF EXISTS `del_observation` ;
|
692 |
gduche |
42 |
|
1870 |
jpm |
43 |
CREATE TABLE IF NOT EXISTS `del_observation` (
|
|
|
44 |
`id_observation` BIGINT NOT NULL AUTO_INCREMENT,
|
|
|
45 |
`ce_utilisateur` INT NOT NULL,
|
|
|
46 |
`nom_sel` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Nom scientifique sélectionné par l\'utilisateur.',
|
|
|
47 |
`nom_sel_nn` DECIMAL(9,0) NULL DEFAULT NULL COMMENT 'Identifiant du nom sélectionné.',
|
|
|
48 |
`nom_ret` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Nom scientifique retenu correspondant au nom sélectionné.',
|
|
|
49 |
`nom_ret_nn` DECIMAL(9,0) NULL DEFAULT NULL COMMENT 'Identifiant du nom retenu.',
|
|
|
50 |
`nt` DECIMAL(9,0) NULL DEFAULT NULL COMMENT 'Numéro taxonomique du taxon correspondant au nom sélectionné.',
|
|
|
51 |
`famille` VARCHAR(255) NULL DEFAULT NULL COMMENT 'Nom de la famille du nom sélectionné.',
|
|
|
52 |
`nom_referentiel` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
53 |
`ce_zone_geo` VARCHAR(50) NULL DEFAULT NULL,
|
|
|
54 |
`zone_geo` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
55 |
`lieudit` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
56 |
`station` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
57 |
`milieu` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
58 |
`date_observation` DATETIME NULL,
|
|
|
59 |
`mots_cles_texte` LONGTEXT NULL DEFAULT NULL,
|
|
|
60 |
`commentaire` TEXT NULL DEFAULT NULL,
|
|
|
61 |
`date_creation` DATETIME NOT NULL,
|
|
|
62 |
`date_modification` DATETIME NOT NULL,
|
|
|
63 |
`date_transmission` DATETIME NOT NULL COMMENT 'Date à laquelle l\'observation a été rendu publique.',
|
1987 |
aurelien |
64 |
`certitude` VARCHAR(255) NOT NULL,
|
|
|
65 |
`pays` VARCHAR(2) NOT NULL,
|
1870 |
jpm |
66 |
PRIMARY KEY (`id_observation`))
|
1267 |
jpm |
67 |
ENGINE = MyISAM
|
|
|
68 |
DEFAULT CHARACTER SET = utf8
|
1870 |
jpm |
69 |
COLLATE = utf8_general_ci
|
|
|
70 |
COMMENT = 'Observations publiques.';
|
692 |
gduche |
71 |
|
|
|
72 |
|
1267 |
jpm |
73 |
-- -----------------------------------------------------
|
1870 |
jpm |
74 |
-- Table `del_image`
|
1267 |
jpm |
75 |
-- -----------------------------------------------------
|
1870 |
jpm |
76 |
DROP TABLE IF EXISTS `del_image` ;
|
692 |
gduche |
77 |
|
1870 |
jpm |
78 |
CREATE TABLE IF NOT EXISTS `del_image` (
|
|
|
79 |
`id_image` BIGINT NOT NULL AUTO_INCREMENT,
|
|
|
80 |
`ce_observation` BIGINT NOT NULL,
|
|
|
81 |
`ce_utilisateur` INT NOT NULL,
|
|
|
82 |
`hauteur` INT NULL,
|
|
|
83 |
`largeur` INT NULL,
|
|
|
84 |
`date_prise_de_vue` DATETIME NULL,
|
|
|
85 |
`mots_cles_texte` LONGTEXT NULL DEFAULT NULL,
|
|
|
86 |
`commentaire` LONGTEXT NULL DEFAULT NULL,
|
|
|
87 |
`nom_original` VARCHAR(255) NOT NULL,
|
|
|
88 |
`date_creation` DATETIME NOT NULL,
|
|
|
89 |
`date_modification` DATETIME NOT NULL,
|
|
|
90 |
`date_liaison` DATETIME NOT NULL,
|
|
|
91 |
`date_transmission` DATETIME NOT NULL,
|
|
|
92 |
PRIMARY KEY (`id_image`))
|
|
|
93 |
ENGINE = MEMORY
|
1267 |
jpm |
94 |
DEFAULT CHARACTER SET = utf8
|
1870 |
jpm |
95 |
COLLATE = utf8_general_ci;
|
692 |
gduche |
96 |
|
|
|
97 |
|
1267 |
jpm |
98 |
-- -----------------------------------------------------
|
|
|
99 |
-- Table `del_image_protocole`
|
|
|
100 |
-- -----------------------------------------------------
|
|
|
101 |
DROP TABLE IF EXISTS `del_image_protocole` ;
|
692 |
gduche |
102 |
|
1870 |
jpm |
103 |
CREATE TABLE IF NOT EXISTS `del_image_protocole` (
|
|
|
104 |
`id_protocole` INT NOT NULL AUTO_INCREMENT,
|
|
|
105 |
`intitule` VARCHAR(255) NOT NULL,
|
|
|
106 |
`descriptif` TEXT NULL,
|
|
|
107 |
`tag` VARCHAR(255) NULL,
|
|
|
108 |
`mots_cles` VARCHAR(600) NOT NULL COMMENT 'Mots clés associés au protocole, ceux ci déterminent les mots clés présentés \"à cocher\" dans l\'interface, lorsque le protocole est selectionné',
|
2080 |
aurelien |
109 |
`identifie` BOOLEAN NOT NULL COMMENT 'Indique si être identifié est nécessaire pour voter pour ce protocole',
|
1870 |
jpm |
110 |
PRIMARY KEY (`id_protocole`))
|
1267 |
jpm |
111 |
ENGINE = MyISAM
|
|
|
112 |
DEFAULT CHARACTER SET = utf8
|
|
|
113 |
COLLATE = utf8_general_ci;
|
712 |
jpm |
114 |
|
|
|
115 |
|
1267 |
jpm |
116 |
-- -----------------------------------------------------
|
|
|
117 |
-- Table `del_image_vote`
|
|
|
118 |
-- -----------------------------------------------------
|
|
|
119 |
DROP TABLE IF EXISTS `del_image_vote` ;
|
712 |
jpm |
120 |
|
1870 |
jpm |
121 |
CREATE TABLE IF NOT EXISTS `del_image_vote` (
|
|
|
122 |
`id_vote` BIGINT NOT NULL AUTO_INCREMENT,
|
|
|
123 |
`ce_image` BIGINT NOT NULL,
|
|
|
124 |
`ce_protocole` INT NOT NULL,
|
|
|
125 |
`ce_utilisateur` VARCHAR(32) NOT NULL COMMENT 'Identifiant de session ou id utilisateur.',
|
|
|
126 |
`valeur` TINYINT(1) NOT NULL,
|
|
|
127 |
`date` DATETIME NOT NULL,
|
|
|
128 |
PRIMARY KEY (`id_vote`),
|
|
|
129 |
UNIQUE INDEX `protocole_image_utilisateur` (`ce_image` ASC, `ce_protocole` ASC, `ce_utilisateur` ASC))
|
1267 |
jpm |
130 |
ENGINE = MyISAM
|
|
|
131 |
DEFAULT CHARACTER SET = utf8
|
|
|
132 |
COLLATE = utf8_general_ci;
|
692 |
gduche |
133 |
|
|
|
134 |
|
1267 |
jpm |
135 |
-- -----------------------------------------------------
|
|
|
136 |
-- Table `del_image_tag`
|
|
|
137 |
-- -----------------------------------------------------
|
|
|
138 |
DROP TABLE IF EXISTS `del_image_tag` ;
|
692 |
gduche |
139 |
|
1870 |
jpm |
140 |
CREATE TABLE IF NOT EXISTS `del_image_tag` (
|
|
|
141 |
`id_tag` BIGINT NOT NULL AUTO_INCREMENT,
|
|
|
142 |
`ce_image` BIGINT NOT NULL,
|
2025 |
mathias |
143 |
`ce_utilisateur` VARCHAR(64) NOT NULL,
|
1870 |
jpm |
144 |
`tag` VARCHAR(255) NOT NULL DEFAULT 'Mot clé saisi par l\'utilisateur.',
|
|
|
145 |
`tag_normalise` VARCHAR(255) NOT NULL DEFAULT 'Mot clé normalisé (sans espace ni accent).',
|
|
|
146 |
`date` DATETIME NOT NULL COMMENT 'Date de création du tag.',
|
|
|
147 |
`actif` INT(1) NULL,
|
|
|
148 |
`date_modification` DATETIME NULL,
|
|
|
149 |
PRIMARY KEY (`id_tag`),
|
|
|
150 |
INDEX `tag` (`tag` ASC),
|
|
|
151 |
INDEX `tag_normalise` (`tag_normalise` ASC))
|
1267 |
jpm |
152 |
ENGINE = MyISAM
|
|
|
153 |
DEFAULT CHARACTER SET = utf8
|
|
|
154 |
COLLATE = utf8_general_ci;
|
692 |
gduche |
155 |
|
|
|
156 |
|
1267 |
jpm |
157 |
-- -----------------------------------------------------
|
|
|
158 |
-- Table `del_commentaire`
|
|
|
159 |
-- -----------------------------------------------------
|
|
|
160 |
DROP TABLE IF EXISTS `del_commentaire` ;
|
692 |
gduche |
161 |
|
1870 |
jpm |
162 |
CREATE TABLE IF NOT EXISTS `del_commentaire` (
|
|
|
163 |
`id_commentaire` BIGINT NOT NULL AUTO_INCREMENT,
|
|
|
164 |
`ce_observation` BIGINT NOT NULL,
|
|
|
165 |
`ce_proposition` INT NULL DEFAULT 0,
|
|
|
166 |
`ce_commentaire_parent` BIGINT NULL DEFAULT 0,
|
|
|
167 |
`texte` TEXT NULL DEFAULT NULL,
|
|
|
168 |
`ce_utilisateur` INT NULL DEFAULT '0',
|
|
|
169 |
`utilisateur_prenom` VARCHAR(255) NOT NULL,
|
|
|
170 |
`utilisateur_nom` VARCHAR(255) NOT NULL,
|
|
|
171 |
`utilisateur_courriel` VARCHAR(255) NOT NULL,
|
|
|
172 |
`nom_sel` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
173 |
`nom_sel_nn` DECIMAL(9,0) NULL DEFAULT NULL,
|
|
|
174 |
`nom_ret` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
175 |
`nom_ret_nn` DECIMAL(9,0) NULL DEFAULT NULL,
|
|
|
176 |
`nt` DECIMAL(9,0) NULL DEFAULT NULL,
|
|
|
177 |
`famille` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
178 |
`nom_referentiel` VARCHAR(255) NULL DEFAULT NULL,
|
|
|
179 |
`date` DATETIME NOT NULL COMMENT 'Date de création du commentaire.',
|
|
|
180 |
`proposition_initiale` INT(1) NOT NULL DEFAULT 0 COMMENT 'La proposition initiale est le nom_sel d\'origine copié ici dès lors que des commentaires adviennent.',
|
|
|
181 |
`proposition_retenue` INT(1) NOT NULL DEFAULT 0 COMMENT 'La proposition \"validée\" une fois que l\'auteur à validé et que le nom_sel de cel_obs a été modifié à partir du nom_sel de del_commentaire.',
|
|
|
182 |
`ce_validateur` INT(11) NULL,
|
|
|
183 |
`date_validation` DATETIME NULL,
|
|
|
184 |
PRIMARY KEY (`id_commentaire`))
|
1267 |
jpm |
185 |
ENGINE = MyISAM
|
|
|
186 |
DEFAULT CHARACTER SET = utf8
|
|
|
187 |
COLLATE = utf8_general_ci;
|
692 |
gduche |
188 |
|
|
|
189 |
|
1267 |
jpm |
190 |
-- -----------------------------------------------------
|
|
|
191 |
-- Table `del_commentaire_vote`
|
|
|
192 |
-- -----------------------------------------------------
|
|
|
193 |
DROP TABLE IF EXISTS `del_commentaire_vote` ;
|
1178 |
aurelien |
194 |
|
1870 |
jpm |
195 |
CREATE TABLE IF NOT EXISTS `del_commentaire_vote` (
|
|
|
196 |
`id_vote` BIGINT NOT NULL AUTO_INCREMENT,
|
|
|
197 |
`ce_proposition` BIGINT NOT NULL,
|
|
|
198 |
`ce_utilisateur` VARCHAR(32) NOT NULL DEFAULT '0' COMMENT 'Identifiant de session ou id de l\'utilisateur.',
|
|
|
199 |
`valeur` TINYINT(1) NOT NULL,
|
|
|
200 |
`date` DATETIME NOT NULL,
|
|
|
201 |
PRIMARY KEY (`id_vote`))
|
1267 |
jpm |
202 |
ENGINE = MyISAM
|
|
|
203 |
DEFAULT CHARACTER SET = utf8
|
|
|
204 |
COLLATE = utf8_general_ci
|
|
|
205 |
COMMENT = 'Vote uniquement sur le commentaire de type \'proposition\'.';
|
1178 |
aurelien |
206 |
|
1213 |
aurelien |
207 |
|
1267 |
jpm |
208 |
-- -----------------------------------------------------
|
1870 |
jpm |
209 |
-- Table `del_image_stats`
|
1267 |
jpm |
210 |
-- -----------------------------------------------------
|
1870 |
jpm |
211 |
DROP TABLE IF EXISTS `del_image_stats` ;
|
1213 |
aurelien |
212 |
|
1870 |
jpm |
213 |
CREATE TABLE IF NOT EXISTS `del_image_stats` (
|
|
|
214 |
`ce_image` BIGINT(20) NOT NULL COMMENT 'id_image (tb_cel.cel_images)',
|
|
|
215 |
`ce_protocole` TINYINT NOT NULL DEFAULT 0 COMMENT 'un id de protocole',
|
|
|
216 |
`moyenne` FLOAT NOT NULL DEFAULT 0 COMMENT 'moyenne des votes pour une image et un protocole donné',
|
|
|
217 |
`nb_votes` SMALLINT NOT NULL DEFAULT 0 COMMENT 'nombre de votes pour une image et un protocole donné',
|
|
|
218 |
`nb_tags` TINYINT NOT NULL DEFAULT 0 COMMENT 'nombre de tags pictoflora associés à une image',
|
|
|
219 |
PRIMARY KEY (`ce_image`, `ce_protocole`),
|
|
|
220 |
INDEX `ce_image` (`ce_image` ASC),
|
|
|
221 |
INDEX `ce_protocole` (`ce_protocole` ASC, `moyenne` DESC),
|
|
|
222 |
INDEX `nb_tags` (`nb_tags` DESC),
|
|
|
223 |
INDEX `nb_votes` (`nb_votes` DESC))
|
1267 |
jpm |
224 |
ENGINE = MyISAM
|
|
|
225 |
DEFAULT CHARACTER SET = utf8
|
1870 |
jpm |
226 |
COMMENT = 'table de stockage des statistiques utilisées pour les tri de /* comment truncated */ /* PictoFlora*/';
|
1213 |
aurelien |
227 |
|
1267 |
jpm |
228 |
|
1376 |
raphael |
229 |
-- -----------------------------------------------------
|
1870 |
jpm |
230 |
-- Placeholder table for view `del_utilisateurs`
|
1376 |
raphael |
231 |
-- -----------------------------------------------------
|
1870 |
jpm |
232 |
CREATE TABLE IF NOT EXISTS `del_utilisateurs` (`id_utilisateur` INT, `prenom` INT, `nom` INT, `courriel` INT, `mot_de_passe` INT);
|
1376 |
raphael |
233 |
|
1870 |
jpm |
234 |
-- -----------------------------------------------------
|
|
|
235 |
-- Placeholder table for view `del_observations`
|
|
|
236 |
-- -----------------------------------------------------
|
|
|
237 |
CREATE TABLE IF NOT EXISTS `del_observations` (`id_observation` INT, `ce_utilisateur` INT, `prenom_utilisateur` INT, `nom_utilisateur` INT, `courriel_utilisateur` INT, `nom_sel` INT, `nom_sel_nn` INT, `nom_ret` INT, `nom_ret_nn` INT, `nt` INT, `famille` INT, `ce_zone_geo` INT, `zone_geo` INT, `lieudit` INT, `station` INT, `milieu` INT, `nom_referentiel` INT, `date_observation` INT, `mots_cles_texte` INT, `commentaire` INT, `date_creation` INT, `date_modification` INT, `date_transmission` INT, `certitude` INT);
|
1376 |
raphael |
238 |
|
1870 |
jpm |
239 |
-- -----------------------------------------------------
|
|
|
240 |
-- Placeholder table for view `del_images`
|
|
|
241 |
-- -----------------------------------------------------
|
|
|
242 |
CREATE TABLE IF NOT EXISTS `del_images` (`id_image` INT, `ce_observation` INT, `ce_utilisateur` INT, `prenom_utilisateur` INT, `nom_utilisateur` INT, `courriel_utilisateur` INT, `hauteur` INT, `largeur` INT, `date_prise_de_vue` INT, `mots_cles_texte` INT, `commentaire` INT, `nom_original` INT, `date_creation` INT, `date_modification` INT, `date_liaison` INT, `date_transmission` INT);
|
1376 |
raphael |
243 |
|
1870 |
jpm |
244 |
-- -----------------------------------------------------
|
|
|
245 |
-- Placeholder table for view `v_del_image`
|
|
|
246 |
-- -----------------------------------------------------
|
|
|
247 |
CREATE TABLE IF NOT EXISTS `v_del_image` (`id_image` INT, `i_ce_utilisateur` INT, `i_prenom_utilisateur` INT, `i_nom_utilisateur` INT, `i_courriel_utilisateur` INT, `hauteur` INT, `largeur` INT, `date_prise_de_vue` INT, `i_mots_cles_texte` INT, `i_commentaire` INT, `nom_original` INT, `date_creation` INT, `date_modification` INT, `date_liaison` INT, `date_transmission` INT);
|
1376 |
raphael |
248 |
|
1870 |
jpm |
249 |
-- -----------------------------------------------------
|
|
|
250 |
-- View `del_utilisateurs`
|
|
|
251 |
-- -----------------------------------------------------
|
|
|
252 |
DROP VIEW IF EXISTS `del_utilisateurs` ;
|
|
|
253 |
DROP TABLE IF EXISTS `del_utilisateurs`;
|
|
|
254 |
CREATE OR REPLACE VIEW del_utilisateur AS
|
|
|
255 |
SELECT
|
|
|
256 |
U_ID AS id_utilisateur,
|
|
|
257 |
CONVERT(U_SURNAME USING UTF8) AS prenom,
|
|
|
258 |
CONVERT(U_NAME USING UTF8) AS nom,
|
|
|
259 |
CONVERT(U_MAIL USING UTF8) AS courriel,
|
|
|
260 |
CONVERT(U_PASSWD USING UTF8) AS mot_de_passe
|
|
|
261 |
FROM tela_prod_v4.annuaire_tela;
|
|
|
262 |
|
|
|
263 |
-- -----------------------------------------------------
|
|
|
264 |
-- View `del_observations`
|
|
|
265 |
-- -----------------------------------------------------
|
|
|
266 |
DROP VIEW IF EXISTS `del_observations` ;
|
|
|
267 |
DROP TABLE IF EXISTS `del_observations`;
|
|
|
268 |
CREATE OR REPLACE VIEW del_observation AS
|
1979 |
aurelien |
269 |
SELECT id_observation,
|
1870 |
jpm |
270 |
if((char_length(o.ce_utilisateur) <> 32),cast(o.ce_utilisateur as unsigned),0) AS ce_utilisateur,
|
|
|
271 |
o.prenom_utilisateur, o.nom_utilisateur, o.courriel_utilisateur,
|
|
|
272 |
nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille,
|
|
|
273 |
ce_zone_geo, zone_geo, lieudit, station, milieu, nom_referentiel,
|
|
|
274 |
date_observation, o.mots_cles_texte, o.commentaire,
|
1987 |
aurelien |
275 |
o.date_creation, o.date_modification, o.date_transmission, certitude, pays
|
1979 |
aurelien |
276 |
FROM tb_cel.cel_obs AS o WHERE o.id_observation IN (SELECT i.ce_observation FROM tb_cel.cel_images i)
|
|
|
277 |
AND o.transmission = '1';
|
1870 |
jpm |
278 |
|
|
|
279 |
-- -----------------------------------------------------
|
|
|
280 |
-- View `del_images`
|
|
|
281 |
-- -----------------------------------------------------
|
|
|
282 |
DROP VIEW IF EXISTS `del_images` ;
|
|
|
283 |
DROP TABLE IF EXISTS `del_images`;
|
|
|
284 |
CREATE OR REPLACE VIEW del_image AS
|
|
|
285 |
SELECT i.id_image, i.ce_observation,
|
|
|
286 |
if((char_length(i.ce_utilisateur) <> 32),cast(i.ce_utilisateur as unsigned),0) AS ce_utilisateur, i.prenom_utilisateur, i.nom_utilisateur, i.courriel_utilisateur,
|
|
|
287 |
i.hauteur, i.largeur, i.date_prise_de_vue, i.mots_cles_texte, i.commentaire, i.nom_original,
|
|
|
288 |
i.date_creation, i.date_modification, i.date_liaison, i.date_transmission
|
|
|
289 |
FROM tb_cel.cel_images AS i
|
|
|
290 |
WHERE i.transmission = '1';
|
|
|
291 |
|
|
|
292 |
-- -----------------------------------------------------
|
1880 |
jpm |
293 |
-- View `del_plantnet`
|
1870 |
jpm |
294 |
-- -----------------------------------------------------
|
1880 |
jpm |
295 |
DROP VIEW IF EXISTS `del_plantnet` ;
|
|
|
296 |
DROP TABLE IF EXISTS `del_plantnet`;
|
|
|
297 |
CREATE OR REPLACE VIEW del_plantnet AS
|
2128 |
mathias |
298 |
SELECT `o`.`id_observation` AS `id_observation`,`o`.`ce_utilisateur` AS `ce_utilisateur`,`o`.`prenom_utilisateur` AS `prenom_utilisateur`,
|
|
|
299 |
`o`.`nom_utilisateur` AS `nom_utilisateur`,`o`.`courriel_utilisateur` AS `courriel_utilisateur`,`o`.`nom_sel` AS `nom_sel`,
|
|
|
300 |
`o`.`nom_sel_nn` AS `nom_sel_nn`,`o`.`nom_ret` AS `nom_ret`,`o`.`famille` AS `famille`,`o`.`nom_referentiel` AS `nom_referentiel`,
|
|
|
301 |
`o`.`zone_geo` AS `zone_geo`,`o`.`latitude` AS `latitude`,`o`.`longitude` AS `longitude`,`o`.`altitude` AS `altitude`,
|
|
|
302 |
`o`.`date_observation` AS `date_observation`,`o`.`mots_cles_texte` AS `mots_cles_texte`,`o`.`date_creation` AS `date_creation`,
|
|
|
303 |
`o`.`date_modification` AS `date_modification`,`o`.`date_transmission` AS `date_transmission`,`i`.`id_image` AS `id_image`,
|
|
|
304 |
`i`.`ce_utilisateur` AS `i_ce_utilisateur`,`i`.`mots_cles_texte` AS `i_mots_cles_texte`,`i`.`nom_original` AS `nom_original`,
|
|
|
305 |
`i`.`date_creation` AS `i_date_creation`,`i`.`date_modification` AS `i_date_modification`
|
|
|
306 |
FROM (`tb_cel_test`.`cel_obs` `o`
|
|
|
307 |
JOIN `tb_cel_test`.`cel_images` `i` ON ((`o`.`id_observation` = `i`.`ce_observation`)))
|
|
|
308 |
WHERE (`o`.`transmission` = '1');
|
1870 |
jpm |
309 |
|
1267 |
jpm |
310 |
SET SQL_MODE=@OLD_SQL_MODE;
|
|
|
311 |
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
1270 |
jpm |
312 |
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
1870 |
jpm |
313 |
|
|
|
314 |
-- -----------------------------------------------------
|
|
|
315 |
-- Data for table `del_image_protocole`
|
|
|
316 |
-- -----------------------------------------------------
|
|
|
317 |
START TRANSACTION;
|
2080 |
aurelien |
318 |
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (3, 'Capitalisation d\'images', 'photographier en extérieur les organes (feuille, fruit, tronc, etc.) de plantes et transmettre les photos via le Carnet en ligne.', 'Plantnet', 'port,fleur,fruit,feuille,plantscan_new,ecorce,rameau,planche', '0');
|
|
|
319 |
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (1, 'Aide à l\'identification', 'Choisissez les photos les plus utiles pour vérifier la détermination d\'une espèce', 'caractere', '', '0');
|
|
|
320 |
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (4, 'Défi Photo', 'Choisissez les lauréats du défi photo', '', '', '1');
|
|
|
321 |
INSERT INTO `del_image_protocole` (`id_protocole`, `intitule`, `descriptif`, `tag`, `mots_cles`) VALUES (5, 'Enquête Gentiane-Azuré', 'Participez à la localisation des Gentianes Croisette, témoins et actrices du cycle de vie du papillon Azuré de la Croisette\r\n', 'GentianeAzure', '', '0');
|
1870 |
jpm |
322 |
|
2148 |
killian |
323 |
|
|
|
324 |
-- -----------------------------------------------------
|
|
|
325 |
-- Table de données calculées pour le service d'export
|
|
|
326 |
-- PlantNet
|
|
|
327 |
--
|
|
|
328 |
-- Comporte la date dernière mise à jour d'une obs et
|
|
|
329 |
-- des données liées
|
|
|
330 |
-- -----------------------------------------------------
|
|
|
331 |
CREATE TABLE del_observation_modif_date
|
|
|
332 |
(
|
|
|
333 |
id_observation BIGINT NOT NULL,
|
|
|
334 |
modif_date datetime,
|
|
|
335 |
|
|
|
336 |
UNIQUE (id_observation)
|
|
|
337 |
)
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
-- -----------------------------------------------------
|
|
|
341 |
-- Initialisation des dates de dernière màj d'une obs et
|
|
|
342 |
-- de ses données liées
|
|
|
343 |
-- -----------------------------------------------------
|
|
|
344 |
INSERT INTO del_observation_modif_date (id_observation, modif_date)
|
|
|
345 |
SELECT DISTINCT p.id_observation,
|
|
|
346 |
GREATEST(IFNULL(p.date_creation, '1900-01-01'), IFNULL(p.date_modification, '1900-01-01'), IFNULL(MAX(image_tag.date), '1900-01-01'), IFNULL(MAX(image_tag.date_modification), '1900-01-01'), IFNULL(MAX(image_vote.date), '1900-01-01'), IFNULL(MAX(commentaire.date), '1900-01-01'), IFNULL(MAX(commentaire_vote.date), '1900-01-01')) AS modif_date
|
|
|
347 |
FROM del_plantnet AS p
|
|
|
348 |
LEFT JOIN del_image_vote AS image_vote ON (id_image = image_vote.ce_image
|
|
|
349 |
AND image_vote.ce_protocole = 3)
|
|
|
350 |
LEFT JOIN del_image_tag AS image_tag ON (id_image = image_tag.ce_image
|
|
|
351 |
AND image_tag.actif = 1)
|
|
|
352 |
LEFT JOIN del_commentaire AS commentaire ON (id_observation = commentaire.ce_observation)
|
|
|
353 |
LEFT JOIN del_commentaire_vote AS commentaire_vote ON (commentaire.id_commentaire = commentaire_vote.ce_proposition)
|
|
|
354 |
GROUP BY id_observation
|
|
|
355 |
HAVING MAX(p.date_creation) >= '1900-01-01'
|
|
|
356 |
OR MAX(p.date_modification) >= '1900-01-01'
|
|
|
357 |
OR MAX(image_tag.date) >= '1900-01-01'
|
|
|
358 |
OR MAX(image_tag.date_modification) >= '1900-01-01'
|
|
|
359 |
OR MAX(image_vote.date) >= '1900-01-01'
|
|
|
360 |
OR MAX(commentaire.date) >= '1900-01-01'
|
|
|
361 |
OR MAX(commentaire_vote.date) >= '1900-01-01'
|
|
|
362 |
|
|
|
363 |
-- -----------------------------------------------------
|
|
|
364 |
-- Triggers pour garder à jour les dates de dernière màj
|
|
|
365 |
-- d'une obs et de ses données liées
|
|
|
366 |
-- -----------------------------------------------------
|
|
|
367 |
-- cel_obs INSERT trigger --
|
2151 |
mathias |
368 |
DROP TRIGGER IF EXISTS tb_cel.TRIGGER_celObs_dateModif_INSERT;
|
2148 |
killian |
369 |
CREATE TRIGGER tb_cel.TRIGGER_celObs_dateModif_INSERT
|
|
|
370 |
AFTER INSERT ON tb_cel.cel_obs FOR EACH ROW
|
|
|
371 |
INSERT INTO tb_del.del_observation_modif_date (id_observation, modif_date)
|
|
|
372 |
VALUES (NEW.id_observation, NEW.date_creation);
|
|
|
373 |
|
|
|
374 |
-- cel_obs UPDATE trigger --
|
|
|
375 |
CREATE TRIGGER tb_cel.TRIGGER_celObs_dateModif_UPDATE
|
|
|
376 |
AFTER UPDATE ON tb_cel.cel_obs FOR EACH ROW
|
|
|
377 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.date_modification
|
|
|
378 |
WHERE id_observation = NEW.id_observation;
|
|
|
379 |
|
|
|
380 |
|
|
|
381 |
|
|
|
382 |
-- del_commentaire INSERT trigger --
|
|
|
383 |
CREATE TRIGGER tb_del.TRIGGER_delCommentaire_dateModif_INSERT
|
|
|
384 |
AFTER INSERT ON tb_del.del_commentaire FOR EACH ROW
|
|
|
385 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
|
|
|
386 |
WHERE id_observation = NEW.ce_observation;
|
|
|
387 |
|
|
|
388 |
-- del_commentaire UPDATE trigger --
|
|
|
389 |
CREATE TRIGGER tb_del.TRIGGER_delCommentaire_dateModif_UPDATE
|
|
|
390 |
AFTER UPDATE ON tb_del.del_commentaire FOR EACH ROW
|
|
|
391 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
|
|
|
392 |
WHERE id_observation = NEW.ce_observation;
|
|
|
393 |
|
|
|
394 |
|
|
|
395 |
|
|
|
396 |
-- del_commentaire_vote INSERT trigger --
|
|
|
397 |
CREATE TRIGGER tb_del.TRIGGER_delCommentaireVote_dateModif_INSERT
|
|
|
398 |
AFTER INSERT ON tb_del.del_commentaire_vote FOR EACH ROW
|
|
|
399 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
|
|
|
400 |
WHERE id_observation = (SELECT ce_observation FROM tb_del.del_commentaire WHERE id_commentaire = NEW.ce_proposition);
|
|
|
401 |
|
|
|
402 |
-- del_commentaire_vote UPDATE trigger --
|
|
|
403 |
CREATE TRIGGER tb_del.TRIGGER_delCommentaireVote_dateModif_UPDATE
|
|
|
404 |
AFTER UPDATE ON tb_del.del_commentaire_vote FOR EACH ROW
|
|
|
405 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
|
|
|
406 |
WHERE id_observation = (SELECT ce_observation FROM tb_del.del_commentaire WHERE id_commentaire = NEW.ce_proposition);
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
|
410 |
-- del_image_vote INSERT trigger --
|
|
|
411 |
CREATE TRIGGER tb_del.TRIGGER_delImageVote_dateModif_INSERT
|
|
|
412 |
AFTER INSERT ON tb_del.del_image_vote FOR EACH ROW
|
|
|
413 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
|
|
|
414 |
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
|
|
|
415 |
|
|
|
416 |
-- del_image_vote UPDATE trigger --
|
|
|
417 |
CREATE TRIGGER tb_del.TRIGGER_delImageVote_dateModif_UPDATE
|
|
|
418 |
AFTER UPDATE ON tb_del.del_image_vote FOR EACH ROW
|
|
|
419 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
|
|
|
420 |
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
|
|
|
421 |
|
|
|
422 |
|
|
|
423 |
|
|
|
424 |
-- del_image_tag INSERT trigger --
|
|
|
425 |
CREATE TRIGGER tb_del.TRIGGER_delImageTag_dateModif_INSERT
|
|
|
426 |
AFTER INSERT ON tb_del.del_image_tag FOR EACH ROW
|
|
|
427 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
|
|
|
428 |
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
|
|
|
429 |
|
|
|
430 |
-- del_image_tag UPDATE trigger --
|
|
|
431 |
CREATE TRIGGER tb_del.TRIGGER_delImageTag_dateModif_UPDATE
|
|
|
432 |
AFTER UPDATE ON tb_del.del_image_tag FOR EACH ROW
|
|
|
433 |
UPDATE tb_del.del_observation_modif_date SET modif_date = NEW.`date`
|
|
|
434 |
WHERE id_observation = (SELECT ce_observation FROM tb_cel.cel_images WHERE id_image = NEW.ce_image);
|
|
|
435 |
|
|
|
436 |
-- -----------------------------------------------------
|
|
|
437 |
-- Fin des triggers pour garder à jour les dates de
|
|
|
438 |
-- dernière màj d'une obs et de ses données liées
|
|
|
439 |
-- -----------------------------------------------------
|
|
|
440 |
|
|
|
441 |
|
1979 |
aurelien |
442 |
COMMIT;
|