From bca07464909b546b3baf9d187c8905bf4514fffe Mon Sep 17 00:00:00 2001 From: Morph01 Date: Thu, 18 Apr 2024 17:12:37 +0200 Subject: [PATCH] =?UTF-8?q?le=20pat=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/script_creation_dataset.sql | 12 ++++++++---- sql/script_migration_data.sql | 18 +++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/sql/script_creation_dataset.sql b/sql/script_creation_dataset.sql index 49fffda..1a81012 100644 --- a/sql/script_creation_dataset.sql +++ b/sql/script_creation_dataset.sql @@ -36,6 +36,7 @@ CREATE TABLE rang INTEGER DEFAULT NULL ); +-- lancer de dé dans un tour CREATE TABLE comprend ( PRIMARY KEY (idpartie, num_tour, idlancer, numero_lancer_dans_tour), @@ -52,18 +53,21 @@ CREATE TABLE couleur VARCHAR(42) ); +-- un roulement de 1 dé dans un lancer de 6 dés CREATE TABLE de_lance ( - PRIMARY KEY (idlancer, rang_couleur_valeur), - idlancer INTEGER NOT NULL AUTO_INCREMENT, + PRIMARY KEY (roulement_de_de, rang_couleur_valeur, idlancer), + roulement_de_de INTEGER NOT NULL AUTO_INCREMENT, + idlancer INTEGER NOT NULL, rang_couleur_valeur VARCHAR(42) NOT NULL ); +-- un lancer de 6 dés CREATE TABLE effectue ( - PRIMARY KEY (idjoueur, idlancer), + PRIMARY KEY (idlancer), idjoueur INTEGER NOT NULL, - idlancer INTEGER NOT NULL + idlancer INTEGER NOT NULL AUTO_INCREMENT ); CREATE TABLE diff --git a/sql/script_migration_data.sql b/sql/script_migration_data.sql index 8273fcb..525bd92 100644 --- a/sql/script_migration_data.sql +++ b/sql/script_migration_data.sql @@ -284,7 +284,7 @@ WHERE SET @row_number = 0; -INSERT INTO `comprend`(`idpartie`, `num_tour`, `idlancer`) SELECT `id_partie`, `numTour`, @row_number:=@row_number+1 AS idlancers +INSERT INTO `comprend`(`idpartie`, `num_tour`, `idlancer`, `numero_lancer_dans_tour`) SELECT `id_partie`, `numTour`, @row_number:=@row_number+1 AS idlancers_de_de, numL FROM donnees_fournies.instances3 t; SET @row_number = 0; @@ -292,14 +292,14 @@ INSERT INTO `effectue`(`idjoueur`, `idlancer`) SELECT inst3.id_joueur, @row_number:=@row_number+1 AS idlancer FROM donnees_fournies.instances3 inst3; -SET @idlancer = 0; -INSERT INTO `de_lance`(`idlancer`, `rang_couleur_valeur`) -SELECT @idlancer:=@idlancer+1 AS idlancer, CONCAT('1;', de1) AS rang_couleur_valeur FROM `donnees_fournies`.`instances3` -UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('2;', de2) FROM `donnees_fournies`.`instances3` -UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('3;', de3) FROM `donnees_fournies`.`instances3` -UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('4;', de4) FROM `donnees_fournies`.`instances3` -UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('5;', de5) FROM `donnees_fournies`.`instances3` -UNION ALL SELECT @idlancer:=@idlancer+1, CONCAT('6;', de6) FROM `donnees_fournies`.`instances3`; +SET @roulement = 0; +INSERT INTO `de_lance`(`roulement_de_de`, `rang_couleur_valeur`, `idlancer`) +SELECT @roulement:=@roulement+1 AS roulement, CONCAT('1;', de1) AS rang_couleur_valeur, (FLOOR((@roulement-1)/6) + 1) AS idlancer FROM `donnees_fournies`.`instances3` +UNION ALL SELECT @roulement:=@roulement+1, CONCAT('2;', de2), (FLOOR((@roulement-1)/6) + 1) AS idlancer FROM `donnees_fournies`.`instances3` +UNION ALL SELECT @roulement:=@roulement+1, CONCAT('3;', de3), (FLOOR((@roulement-1)/6) + 1) AS idlancer FROM `donnees_fournies`.`instances3` +UNION ALL SELECT @roulement:=@roulement+1, CONCAT('4;', de4), (FLOOR((@roulement-1)/6) + 1) AS idlancer FROM `donnees_fournies`.`instances3` +UNION ALL SELECT @roulement:=@roulement+1, CONCAT('5;', de5), (FLOOR((@roulement-1)/6) + 1) AS idlancer FROM `donnees_fournies`.`instances3` +UNION ALL SELECT @roulement:=@roulement+1, CONCAT('6;', de6), (FLOOR((@roulement-1)/6) + 1) AS idlancer FROM `donnees_fournies`.`instances3`; INSERT INTO `joue`(`idjoueur`, `idpartie`, `couleur_pion`, `rang`) SELECT `id_joueur`, `id_partie`, NULL, `rang_arrivee` FROM donnees_fournies.instances1;