IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Schéma Discussion :

Modélisation catégories, sous-catégories, rubriques


Sujet :

Schéma

  1. #61
    Expert éminent sénior
    Avatar de fsmrel
    Homme Profil pro
    Spécialiste en bases de données
    Inscrit en
    Septembre 2006
    Messages
    8 113
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Spécialiste en bases de données
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2006
    Messages : 8 113
    Points : 31 588
    Points
    31 588
    Billets dans le blog
    16
    Par défaut Ligne à ligne
    Bonsoir almoha,


    Citation Envoyé par almoha
    La 1re phrase s'affiche; l'utilisateur indique sa réponse; l'application lui indique s'il a fourni la bonne réponse et affiche la règle associée;
    * La 2e phrase s'affiche; l'utilisateur indique sa réponse; l'application lui indique s'il a fourni la bonne réponse et affiche la règle associée;
    * etc, jusqu'à ce que toutes les phrases associées à la règle aient été affichées et que l'utilisateur ait fourni ses réponses.

    Prenons par exemple le cas de la requête R4 :

    Raoul a choisi la partie 1 : « formes et accords du verbe », puis la sous-partie 5 : « Le verbe et ses formes », puis la rubrique 9 : « L’imparfait du subjonctif », puis la règle 6 : « La 3e personne du pluriel », pour obtenir finalement la liste des phrases qui lui sont proposées en fonction du niveau de difficulté, 2 en l’occurrence (et dans un ordre aléatoire). Le résultat obtenu est le suivant :

     
    rg6, ph6, 2, Qu'elles vous plussent
    rg6, ph7, 2, Qu'elles ne pussent résister
    rg6, ph4, 2, Et qu'ils vous idolâtrassent
    rg6, ph5, 2, Pour que vous m'assassinassiez
    rg6, ph8, 2, Qu'ils sursissent
    rg6, ph3, 2, Fallait-il qu'ils vous aimassent
     
    
    Je propose que ce résultat soit stocké et numéroté dans une table ad-hoc, appelons-la PROPOSITION, telle qu’un SELECT appliqué à deux de ses colonnes, NumeroLigne et ElementNom, soit le suivant (numérotation dans l’ordre défini par la fonction RAND()) :

     
    NumeroLigne    ElementNom 
              1    rg6, ph6, 2, Qu'elles vous plussent
              2    rg6, ph7, 2, Qu'elles ne pussent résister
              3    rg6, ph4, 2, Et qu'ils vous idolâtrassent
              4    rg6, ph5, 2, Pour que vous m'assassinassiez
              5    rg6, ph8, 2, Qu'ils sursissent
              6    rg6, ph3, 2, Fallait-il qu'ils vous aimassent
     
    
    Ainsi, pour proposer à Raoul les phrases une à une, dans votre application, vous pouvez sélectionner dans la table PROPOSITION la 1ere ligne (NumeroLigne = 1), la soumettre à Raoul, noter sa réponse, puis sélectionner la 2e ligne, etc., jusqu’à la dernière, c'est-à-dire celle dont le numéro est égal à (SELECT COUNT(*) FROM PROPOSITION).

    Pour produire la table PROPOSITION, je procède ainsi :

    1) Déclaration de la table :

     
    CREATE TEMPORARY TABLE PROPOSITION
    (
            NumeroLigne          INT             NOT NULL AUTO_INCREMENT
          , Alea                 FLOAT           NOT NULL DEFAULT 0    
          , TypeParentId         INT             NOT NULL
          , TypeParentNom        VARCHAR(16)     NOT NULL       
          , ElementParentId      INT             NOT NULL
          , ElementParentNom     VARCHAR(64)     NOT NULL
          , TypeElementId        INT             NOT NULL
          , TypeElementNom       VARCHAR(16)     NOT NULL
          , ElementId            INT             NOT NULL   
          , ElementNom           VARCHAR(96)     NOT NULL DEFAULT ''
        , CONSTRAINT PROPOSITION_PK PRIMARY KEY (NumeroLigne)      
        , CONSTRAINT PROPOSITION_AK UNIQUE (ElementParentId, TypeElementId, ElementId)  
    ) ;
     
    
    Cette structure est à peu de choses près celle de la table PILE, avec en prime les deux colonnes suivantes, NumeroLigne et Alea :

    NumeroLigne, dont l’objet est justement de vous faciliter la vie pour accéder aux phrases, une par une, selon l’ordre aléatoire figurant dans Alea.

    A la limite, on peut supprimer de cette table les colonnes que vous estimerez inutiles.

    Cette table est du type temporaire (cf. CREATE TEMPORARY TABLE), de telle sorte que Fernand, Raoul et les autres, puissent plancher en même temps, chacun avec sa propre table, sans inter-blocage (phénomène dont nous n’avons pas traité jusqu’ici et pouvant amener à rendre temporaires d’autres tables, du genre PILE, pouvant entrer en concurrence en mise à jour).

    La mise en œuvre de la table PROPOSITION a pour effet la modification de la procédure RaoulNavigue dans laquelle les SELECT sont remplacés par des INSERT dans cette table :

     
    -- --------------------------------------------------------------------------------------
    -- Requête Rxy
    -- Raoul a choisi un sujet (TypeElementId = x et ElementId = y)
    -- Pour avoir la descendance directe : TypeParentId = x et ElementParentId = y.
    -- Si le descendant est une phrase (TypeElementId = 5), et si Raoul veut 
    -- seulement travailler sur un certain niveau de difficulté (DifficulteChoisie > 0),
    -- alors on filtre sur ce niveau.  
    -- --------------------------------------------------------------------------------------
     
    CREATE PROCEDURE RaoulNavigue
    (
       IN TypeParentChoisiId INT, ParentChoisiId INT, DifficulteChoisie INT
    )
     
    BEGIN
     
    DECLARE theNumeroLigne INT ;
     
    -- Pour réutiliser la table, on commence par virer ce qui a déjà été traité
     
    DELETE FROM PROPOSITION ;
     
    IF DifficulteChoisie = 0 OR TypeParentChoisiId < 4 THEN
        INSERT INTO PROPOSITION
                   (TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom)  
            SELECT  TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom 
            FROM    PILE
            WHERE   TypeParentId = TypeParentChoisiId AND ElementParentId = ParentChoisiId 
            ORDER BY ElementParentId, TypeElementId ; -- Pour avoir dans l'ordre des types d'élément par partie
    ELSE
        INSERT INTO PROPOSITION
                   (Alea, TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom)    
            SELECT  RAND() AS Alea, TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom 
            FROM    PILE
            WHERE   TypeParentId = TypeParentChoisiId AND ElementParentId = ParentChoisiId
              AND   Difficulte = DifficulteChoisie
              AND   TypeElementId = 5                      -- 5 : l'élément est de type phrase
            ORDER BY Alea ;
     
    END IF ;
     
    -- Comme MySQL ne réinitialise pas à 1 l’auto-incrémentation, on s’en charge
     
    SET theNumeroLigne = (SELECT COALESCE(MIN(NumeroLigne), 0)  FROM PROPOSITION) ;
     
    UPDATE PROPOSITION 
        SET NumeroLigne = NumeroLigne + 1 - theNumeroLigne ;
     
    END 
     
    GO
     
    
    Pour le reste, pas de changement. Ainsi pour exécuter la requête R4 :

     
    -- --------------------------------------------------------------------------------------
    -- Requête R4
    -- Raoul a choisi "La 3e personne du pluriel" (TypeElementId = 4 et ElementId = 6)
    -- Pour avoir la descendance directe : TypeParentId = 4 et ElementParentId = 6.
    -- --------------------------------------------------------------------------------------
     
    SET @TypeParentId  = 4 ;
    SET @ElementParentId = 6 ;  
    SET @Difficulte = 2 ;
     
    -- CALL RaoulNavigue(@TypeParentId, @ElementParentId, @Difficulte) ;
    CALL RaoulNavigue(4, 6, 2) ;
     
    
    Et pour afficher le résultat obtenu :

     
    SELECT Numeroligne, ElementNom FROM PROPOSITION ORDER BY NumeroLigne ;
     
    
    =>

     
    NumeroLigne    ElementNom 
              1    rg6, ph6, 2, Qu'elles vous plussent
              2    rg6, ph7, 2, Qu'elles ne pussent résister
              3    rg6, ph4, 2, Et qu'ils vous idolâtrassent
              4    rg6, ph5, 2, Pour que vous m'assassinassiez
              5    rg6, ph8, 2, Qu'ils sursissent
              6    rg6, ph3, 2, Fallait-il qu'ils vous aimassent
     
    

    Un paquet complet, from cradle to grave :

     
    USE temp ; 
     
    DROP TABLE IF EXISTS PILE ; 
    DROP TEMPORARY TABLE IF EXISTS PROPOSITION ;
     
    DROP TABLE IF EXISTS SELECTION ;
    DROP TABLE IF EXISTS INTERROGATION ;
    DROP TABLE IF EXISTS QUESTIONNAIRE_PHRASE ;
    DROP TABLE IF EXISTS QUESTIONNAIRE ;
    DROP TABLE IF EXISTS PHRASES_NB ;
     
    DROP TABLE IF EXISTS REPONDRE ;
    DROP TABLE IF EXISTS CHOISIR ;
     
    DROP TABLE IF EXISTS UTILISATEUR ;
    DROP TABLE IF EXISTS CORRIGE ;
    DROP TABLE IF EXISTS PHRASE ;
    DROP TABLE IF EXISTS DIFFICULTE ;
    DROP TABLE IF EXISTS COMPOSITION ;
    DROP TABLE IF EXISTS REGLE ;
    DROP TABLE IF EXISTS ELEMENT ;
    DROP TABLE IF EXISTS TYPE_ELEMENT ;
     
    -------------------------------------------------------------------------------------------------
     
    CREATE TABLE TYPE_ELEMENT 
    (
            TypeElementId        INT             NOT NULL
          , TypeElementLibelle   VARCHAR(16)     NOT NULL
        , CONSTRAINT TYPE_ELEMENT_PK PRIMARY KEY (TypeElementId)
    ) ;
     
    CREATE TABLE ELEMENT 
    (
            ElementId            INT             NOT NULL
          , TypeElementId        INT             NOT NULL
          , ElementTexte         VARCHAR(64)     NOT NULL
        , CONSTRAINT ELEMENT_PK PRIMARY KEY (ElementId)
        , CONSTRAINT ELEMENT_TYPE_ELEMENT_FK FOREIGN KEY (TypeElementId)
          REFERENCES TYPE_ELEMENT (TypeElementId) ON DELETE CASCADE
    ) ;
     
    CREATE TABLE COMPOSITION 
    (
            ElementComposantId       INT             NOT NULL
          , ElementComposeId         INT             NOT NULL
        , CONSTRAINT COMPOSITION_ELEMENT_COMPOSANT_FK FOREIGN KEY (ElementComposantId)
          REFERENCES ELEMENT (ElementId) ON DELETE CASCADE
        , CONSTRAINT COMPOSITION_ELEMENT_COMPOSE_FK FOREIGN KEY (ElementComposeId)
          REFERENCES ELEMENT (ElementId)      
    ) ;
     
    CREATE TABLE REGLE 
    (
            RegleId              INT             NOT NULL
          , ElementId            INT             NOT NULL        
          , RegleTexte           VARCHAR(64)     NOT NULL
          , NbPhrases            INT             NOT NULL
        , CONSTRAINT REGLE_PK PRIMARY KEY (RegleId)
        , CONSTRAINT REGLE_ELEMENT_FK FOREIGN KEY (ElementId)
          REFERENCES ELEMENT (ElementId)
     ) ;
     
     CREATE TABLE DIFFICULTE 
    (
            DifficulteId         INT             NOT NULL
          , DifficulteNiveau     INT             NOT NULL DEFAULT 1        
          , DifficulteTexte      VARCHAR(32)     NOT NULL
        , CONSTRAINT DIFFICULTE_PK PRIMARY KEY (DifficulteId)
        , CONSTRAINT DIFFICULTE_AK UNIQUE (DifficulteNiveau)    
    ) ;
     
    CREATE TABLE PHRASE 
    (
            RegleId              INT             NOT NULL
          , PhraseId             INT             NOT NULL
          , DifficulteId         INT             NOT NULL
          , Texte                VARCHAR(96)     NOT NULL
        , CONSTRAINT PHRASE_PK PRIMARY KEY (RegleId, PhraseId)
        , CONSTRAINT PHRASE_REGLE_FK FOREIGN KEY (RegleId)
          REFERENCES REGLE (RegleId)
        , CONSTRAINT PHRASE_DIFFICULTE_FK FOREIGN KEY (DifficulteId)
          REFERENCES DIFFICULTE (DifficulteId)
    ) ;
     
    -- --------------------------------------------------------------------
    -- TABLE PILE - Simulation de la jointure récursive
    -- --------------------------------------------------------------------
    CREATE TABLE PILE 
    (
            PileId               INT             NOT NULL AUTO_INCREMENT
          , Niveau               INT             NOT NULL
          , TypeParentId         INT             NOT NULL
          , TypeParentNom        VARCHAR(16)     NOT NULL
          , ElementParentId      INT             NOT NULL
          , ElementParentNom     VARCHAR(64)     NOT NULL
          , TypeElementId        INT             NOT NULL
          , TypeElementNom       VARCHAR(16)     NOT NULL
          , ElementId            INT             NOT NULL
          , ConcatenationNum     VARCHAR(64)     NOT NULL     
          , ElementNom           VARCHAR(96)     NOT NULL DEFAULT ''
          , Difficulte           INT             NOT NULL DEFAULT 0
        , CONSTRAINT PILE_PK PRIMARY KEY (PileId)   
        , CONSTRAINT PILE_AK UNIQUE (ElementParentId, TypeElementId, ElementId)  
    ) ;
     
    -- --------------------------------------------------------------
    -- Table temporaire pour présenter les phrases une à une
    -- --------------------------------------------------------------
     
    CREATE TEMPORARY TABLE PROPOSITION
    (
            NumeroLigne          INT             NOT NULL AUTO_INCREMENT
          , Alea                 FLOAT           NOT NULL DEFAULT 0                         
          , TypeParentId         INT             NOT NULL
          , TypeParentNom        VARCHAR(16)     NOT NULL       
          , ElementParentId      INT             NOT NULL
          , ElementParentNom     VARCHAR(64)     NOT NULL
          , TypeElementId        INT             NOT NULL
          , TypeElementNom       VARCHAR(16)     NOT NULL
          , ElementId            INT             NOT NULL   
          , ElementNom           VARCHAR(96)     NOT NULL DEFAULT ''
        , CONSTRAINT PROPOSITION_PK PRIMARY KEY (NumeroLigne)      
        , CONSTRAINT PROPOSITION_AK UNIQUE (ElementParentId, TypeElementId, ElementId)  
    ) ;
     
    -- -------------------------------------------------------------
    -- Jeu d'essai
    -- -------------------------------------------------------------
     
    INSERT INTO TYPE_ELEMENT (TypeElementId, TypeElementLibelle) VALUES 
        (1, 'Partie'), (2, 'Sous-partie'), (3, 'Rubrique') ;
       
     SELECT * FROM TYPE_ELEMENT ;
     
    INSERT INTO ELEMENT (ElementId, TypeElementId, ElementTexte) VALUES
        (1, 1, 'Formes et accords du verbe')
      , (2, 1, 'Formes et accords du nom, de l''adjectif et de l''adverbe')
      , (3, 1, 'Orthographe lexicale, signes graphiques et syntaxe')
      , (4, 1, 'Ces mots que l''on confond')
      , (5, 2, 'Le verbe : ses formes')
      , (6, 2, 'Syntaxe')
      , (7, 3, 'L''infinitif')
      , (8, 3, 'Les noms : leur féminin, leur pluriel')
      , (9, 3, 'L''imparfait du subjonctif')    
      , (10, 2, 'Le verbe, ses pièges')
      , (14, 3, 'Rubrique-à-brac')
      , (15, 2, 'sous-partie, piège à AK de PILE')  
      , (91, 1, 'Piège à récursivité')
      , (92, 1, 'Piège à récursivité')
      , (93, 2, 'Piège à récursivité')
     ;
     
    SELECT * FROM ELEMENT ;
     
    INSERT INTO COMPOSITION  (ElementComposantId, ElementComposeId) VALUES
         (5,1), (6, 3), (7, 5), (8, 2), (9, 5), (10, 1), (93, 92), (14, 1), (15, 1) 
         ;
     
    SELECT * FROM COMPOSITION ; 
     
    INSERT INTO REGLE (RegleId, ElementId, RegleTexte, NbPhrases) VALUES
        (1, 8, 'Le pluriel des noms : cas généraux', 5)
      , (2, 6, 'est-ce que', 15)
      , (3, 4, 'a ; à', 2)
      , (4, 4, 'ou ; où', 2)  
      , (5, 4, 'or ; hors', 4)  
      , (6, 9, 'La 3e personne du singulier', 5)
      , (7, 9, 'La 3e personne du pluriel', 3)
    -- /*  
      , (8, 5, 'Une règle de la forme spéciale du verbe', 2)
      , (9, 1, 'Accord dissonant du verbe', 2)
      , (10, 14, 'règle-à-brac',5) 
      , (11, 10, 'rg11, enfant de SP10', 5)
      , (12, 10, 'rg12, enfant de SP10', 5)
      , (13, 10, 'rg13, enfant de SP10', 5)
      , (14, 10, 'rg14, enfant de SP10', 5)
      , (15, 1, 'règle, piège à AK de PILE', 2)
    -- */  
      ;
     
    -- SELECT * FROM REGLE ;
     
    INSERT INTO DIFFICULTE (DifficulteId, DifficulteNiveau, DifficulteTexte) VALUES
        (1, 1, 'Facile'), (2, 2, 'Assez facile'), (3, 3, 'Piège classique'), (4, 4, 'Niveau Mérimée') ;  
     
     -- SELECT * FROM DIFFICULTE ;
     
    INSERT INTO PHRASE (RegleId, PhraseId, DifficulteId, Texte) VALUES
        (1, 1, 1, 'rg1, ph1, le petit chat est morts')
      , (1, 2, 2, 'rg1, ph2, il a un petit soucis')
      , (1, 3, 1, 'rg1, ph3, des yeux marrons')
      , (1, 4, 2, 'rg1, ph4, il est huit heure')
      , (1, 5, 3, 'rg1, ph5, Huit cent deux kilos')
      , (3, 1, 2, 'rg3, ph1 , Je vais à Paris')
      , (3, 2, 2, 'rg3, ph2, Pierre a faim')
      , (3, 3, 4, 'rg3, ph3, Ce crayon est a moi') 
      , (4, 1, 1, 'rg4, Il et fort et agile')
      , (4, 2, 1, 'rg4, Elle est grande')
      , (4, 3, 4, 'rg4, Il aime le cuissot de chevreuil')
      , (4, 4, 4, 'rg4, Il aime aussi le cuissot de veau')
      , (4, 5, 3, 'rg4, C''est une imbécillité')
      , (5, 1, 2, 'rg5, ph1')
      , (5, 2, 2, 'rg5, ph2')
     
      , (6, 1, 3, 'rg6, ph1, 3, Qu''ils cinématographiassent cela !')  
      , (6, 2, 3, 'rg6, ph2, 3, Qu''ils n''aimassent pas cela !')
      , (6, 3, 2, 'rg6, ph3, 2, Fallait-il qu''ils vous aimassent')
      , (6, 4, 2, 'rg6, ph4, 2, Et qu''ils vous idolâtrassent')
      , (6, 5, 2, 'rg6, ph5, 2, Pour que vous m''assassinassiez')
      , (6, 6, 2, 'rg6, ph6, 2, Qu''elles vous plussent')
      , (6, 7, 2, 'rg6, ph7, 2, Qu''elles ne pussent résister')
      , (6, 8, 2, 'rg6, ph8, 2, Qu''ils sursissent') 
      , (6, 9, 1, 'rg6, ph9, 1, Qu''ils nageassent dans la mer') 
     
      , (7, 1, 2, 'rg7, ph1, Qu''il aimât cela !')
      , (7, 2, 3, 'rg7, ph2, Qu''il n''aimat pas cela !')
      , (7, 3, 2, 'rg7, ph3, Qu''il eût aimé')
      
      , (8, 1, 2, 'rg8, ph1')
      , (8, 2, 2, 'rg8, ph2')
      , (9, 1, 2, 'rg9, ph1')
      , (9, 2, 1, 'rg9, ph2')
      , (9, 3, 2, 'rg9, ph3')
      , (10, 1, 2, 'rg10, ph1')
      , (10, 2, 2, 'rg10, ph2')
      , (11, 1, 2, 'rg11, ph1')
      , (11, 2, 2, 'rg11, ph2')
      , (12, 1, 2, 'rg12, ph1')
      , (12, 2, 2, 'rg12, ph2')
      , (13, 1, 2, 'rg13, ph1')
      , (13, 2, 2, 'rg13, ph2')
      , (14, 1, 2, 'rg14, ph1')
      , (14, 2, 2, 'rg14, ph2')
    -- */  
    ;
     
    -- SELECT * FROM PHRASE ; 
     
    COMMIT ;
     
    -- ----------------------------------------------------------------
    -- Les procédures
    -- ----------------------------------------------------------------
     
    DROP PROCEDURE IF EXISTS RaoulNavigue ;
    DROP PROCEDURE IF EXISTS RecursonsJoyeusement ;
     
    DELIMITER GO
     
    -- --------------------------------------------------------------------------------------
    -- Requête Rxy
    -- Raoul a choisi un sujet (TypeElementId = x et ElementId = y)
    -- Pour avoir la descendance directe : TypeParentId = x et ElementParentId = y.
    -- Si le descendant est une phrase (TypeElementId = 5), et si Raoul veut 
    -- seulement travailler sur un certain niveau de difficulté (DifficulteChoisie > 0),
    -- alors on filtre sur ce niveau.  
    -- --------------------------------------------------------------------------------------
     
    CREATE PROCEDURE RaoulNavigue
    (
       IN TypeParentChoisiId INT, ParentChoisiId INT, DifficulteChoisie INT
    )
     
    BEGIN
     
    DECLARE theNumeroLigne INT ;
     
    -- Pour réutiliser la table, on commence par virer ce qui a déjà été traité
     
    DELETE FROM PROPOSITION ;
     
    IF DifficulteChoisie = 0 OR TypeParentChoisiId < 4 THEN
        INSERT INTO PROPOSITION
                   (TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom)  
            SELECT  TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom 
            FROM    PILE
            WHERE   TypeParentId = TypeParentChoisiId AND ElementParentId = ParentChoisiId 
            ORDER BY ElementParentId, TypeElementId ; -- Pour avoir dans l'ordre des types d'élément par partie
    ELSE
                    -- RAND() : pour rendre aléatoire l'ordre des phrases dans la table
        INSERT INTO PROPOSITION
                   (Alea, TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom)    
            SELECT  RAND() AS Alea, TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom         
            FROM    PILE
            WHERE   TypeParentId = TypeParentChoisiId AND ElementParentId = ParentChoisiId
              AND   Difficulte = DifficulteChoisie
              AND   TypeElementId = 5                      -- 5 : l'élément est de type phrase
            ORDER BY Alea ;
     
    END IF ;
     
    -- Comme MySQL ne réinitialise pas à 1 l’auto-incrémentation après delete, on s’en charge
     
    SET theNumeroLigne = (SELECT COALESCE(MIN(NumeroLigne), 0)  FROM PROPOSITION) ;
     
    UPDATE PROPOSITION 
        SET NumeroLigne = NumeroLigne + 1 - theNumeroLigne ;
     
    END 
     
    GO
     
    CREATE PROCEDURE RecursonsJoyeusement
    (
       IN Amorce BOOLEAN, ElementIdIn VARCHAR(10)
    )
     
    BEGIN
     
        DECLARE theNiveau INT ;
        DECLARE NiveauRegle INT ;
        DECLARE NiveauPhrase INT ; 
        DECLARE Kount INT ;
        
        SET theNiveau = (SELECT DISTINCT COALESCE(MAX(Niveau) + 1, 1) FROM PILE) ;
           
        IF Amorce = TRUE THEN
       
        -- ----------------------------------------
        -- Niveau 1 (racine)
        -- ----------------------------------------
       
            IF ElementIdIn > 0 THEN
                INSERT INTO PILE (ElementId, TypeElementId, TypeElementNom, Niveau, ElementParentId, ElementParentNom, TypeParentId, TypeParentNom, ConcatenationNum, ElementNom)
                    SELECT ElementIdIn                                                                                    -- Identifiant de l'élément, passé par l'appelant
                         , x.TypeElementId                                                                                -- Identifiant du type de l'élément
                         , COALESCE((SELECT z.TypeElementlibelle                                                          -- Nom du type de l'élément
                                     FROM   COMPOSITION AS x JOIN ELEMENT AS y ON x.ElementComposantId = y.ElementId
                                                             JOIN TYPE_ELEMENT AS z ON y.TypeElementId = z.TypeElementId 
                                     WHERE  x.ElementComposantId = ElementIdIn), '/')  
                         , 1                                                                                              -- Niveau
                         , COALESCE((SELECT ElementComposeId                                                              -- Identifiant du parent de l'élément
                                     FROM   COMPOSITION 
                                     WHERE ElementComposantId = ElementIdIn), 0)
                         , COALESCE((SELECT y.ElementTexte                                                                -- Nom du parent de l'élément
                                     FROM   COMPOSITION AS x JOIN ELEMENT AS y ON x.ElementComposeId = y.ElementId                               
                                     WHERE  x.ElementComposantId = ElementIdIn), '/')
                         , COALESCE((SELECT y.TypeElementId                                                               -- Identifiant du type du parent de l'élément
                                     FROM   COMPOSITION AS x JOIN ELEMENT AS y ON x.ElementComposeId = y.ElementId 
                                     WHERE  x.ElementComposantId = ElementIdIn), 0)
                         , COALESCE((SELECT z.TypeElementlibelle                                                          -- Nom du type du parent de l'élément 
                                     FROM   COMPOSITION AS x JOIN ELEMENT AS y ON x.ElementComposeId = y.ElementId  
                                                             JOIN TYPE_ELEMENT AS z ON y.TypeElementId = z.TypeElementId
                                     WHERE  x.ElementComposantId = ElementIdIn), 0)
                         , RTRIM(CAST(ElementIdIn AS CHAR(4)))                                                            -- Début concaténation des id
                         , x.ElementTexte                                                                                 -- Nom de l'élément   
                    FROM   ELEMENT AS x
                    WHERE  x.ElementId = ElementIdIn  
                ;                          
            ELSE
                -- ---------------------------------------------
                -- ElementIdIn = 0 : on prend tout
                -- ---------------------------------------------
                INSERT INTO PILE (ElementId, TypeElementId, TypeElementNom, Niveau, ElementParentId, ElementParentNom, TypeParentId, TypeParentNom, ConcatenationNum, ElementNom)
                    SELECT ElementId                             -- Identifiant de chaque élément racine (0 : on prend tout)
                         , TypeElementId                          -- Identifiant du type de l'élément (à savoir : 1)
                         , '/'                                    -- TypeElementNom
                         , 1                                       -- Niveau
                         , 0                                       -- Identifiant du parent de l'élément
                         , '/'                                     -- Nom du parent de l'élément
                         , 0                                       -- Identifiant du type du parent de l'élément
                         , '/'                                     -- Nom du type du parent de l'élément                 
                         , RTRIM(CAST(ElementId AS CHAR(4)))       -- Début concaténation des id
                         , ElementTexte                            -- Nom de l'élément           
                    FROM   ELEMENT
                    WHERE  TypeElementId = 1 ;
            END IF ;
           
         -- ------------------------------------------------------------------------------
        -- Niveau 2 (rattachement direct à un racine : sous-partie ou rubrique ou règle)
        -- -------------------------------------------------------------------------------
           
            INSERT INTO PILE (ElementId, TypeElementId, TypeElementNom, Niveau, ElementParentId, ElementParentNom, TypeParentId, TypeParentNom, ConcatenationNum, ElementNom) 
                 SELECT x.ElementComposantId                                                                                    -- Identifiant de l'élément à récupérer
                      , y.TypeElementId                                                                                         -- Identifiant du type de l'élément
                      , u.TypeElementlibelle                                                                                       -- Nom du type de l'élément           
                      , 2                                                                                                       -- Niveau
                      , x.ElementComposeId                                                                                      -- Identifiant du parent de l'élément
                      , z.ElementTexte                                                                                          -- Nom du parent de l'élément
                      , z.TypeElementId                                                                                         -- Identifiant du type du parent de l'élément
                      , t.TypeElementlibelle                                                                                    -- Nom du type du parent de l'élément                 
                      , CONCAT(RTRIM(CAST(x.ElementComposeId AS CHAR(4))), ', ', RTRIM(CAST(x.ElementComposantId AS CHAR(4))))  -- Concaténation des id  
                      , y.ElementTexte                                                                                          -- Nom de l'élément                     
                 FROM   COMPOSITION AS x JOIN ELEMENT AS y ON x.ElementComposantId = y.ElementId
                                         JOIN ELEMENT AS z ON x.ElementComposeId = z.ElementId
                                         JOIN TYPE_ELEMENT AS t ON z.TypeElementId = t.TypeElementId
                                         JOIN TYPE_ELEMENT AS u ON y.TypeElementId = t.TypeElementId   
                 WHERE  x.ElementComposeId = y.ElementId 
                 ;
                
            -- -------------------------------------------
            -- et un tour de manège
            -- -------------------------------------------
     
            CALL RecursonsJoyeusement(FALSE, '') ;
     
        ELSE
     
        -- -----------------------------------------------
        -- Niveau > 2 (sous-partie ou rubrique ou règle)
        -- ----------------------------------------------
       
            SET Kount = (SELECT COUNT(*) 
                         FROM  (SELECT x.ElementComposantId, Niveau  
                                FROM   COMPOSITION AS x INNER JOIN PILE AS y 
                                       ON x.ElementComposeId = y.ElementId
                                WHERE  Niveau = TheNiveau - 1) as truc) ;
            IF Kount > 0 THEN
           
        -- ---------------------------------------------------
        -- Niveau > 2 (on n'a pas atteint le niveau règle)
        -- ---------------------------------------------------
           
                INSERT INTO PILE (ElementId, TypeElementId, TypeElementNom, Niveau, ElementParentId, ElementParentNom, TypeParentId, TypeParentNom, ConcatenationNum, ElementNom) 
                    SELECT x.ElementComposantId                                                                 -- Identifiant de l'élément à récupérer
                         , z.TypeElementId                                                                      -- Identifiant du type de l'élément
                         , v.TypeElementlibelle                                                                 -- Nom du type de l'élément
                         , theNiveau                                                                            -- Niveau
                         , x.ElementComposeId                                                                   -- Identifiant du parent de l'élément
                         , t.ElementTexte                                                                       -- Nom du parent de l'élément                     
                         , t.TypeElementId                                                                      -- Identifiant du type du parent de l'élément
                         , u.TypeElementlibelle                                                                 -- Nom du type du parent de l'élément             
                         , CONCAT(y.ConcatenationNum, ', ', RTRIM(CAST(x.ElementComposantId AS CHAR(4))))       -- Concaténation des id
                         , z.ElementTexte                                                                       -- Nom de l'élément
                     FROM   COMPOSITION AS x JOIN PILE AS y ON x.ElementComposeId = y.ElementId 
                                            JOIN ELEMENT AS z ON x.ElementComposantId = z.ElementId
                                            JOIN ELEMENT AS t ON x.ElementComposeId = t.ElementId
                                            JOIN TYPE_ELEMENT AS u ON t.TypeElementId = u.TypeElementId
                                            JOIN TYPE_ELEMENT AS v ON z.TypeElementId = v.TypeElementId
                   WHERE  Niveau = TheNiveau - 1 ; 
                
                -- -------------------------------------------
                -- et un tour de manège
                -- -------------------------------------------
     
                CALL RecursonsJoyeusement(FALSE, '') ;
               
            ELSE
           
        -- ----------------------------------------
        -- On a atteint le niveau règle
        -- ----------------------------------------
           
                SET NiveauRegle = (SELECT MAX(TypeElementId) + 1 FROM TYPE_ELEMENT) ;  -- Identifiant du type de la règle : id du plus grand type d'élément + 1      
                SET NiveauPhrase = NiveauRegle + 1 ;                                   -- Identifiant du type de la phrase 
            
                -- ----------------------------------------------
                -- Récupération des règles
                -- ----------------------------------------------
     
                INSERT INTO PILE (ElementId, TypeElementId, TypeElementNom, Niveau, ElementParentId, ElementParentNom, TypeParentId, TypeParentNom, ConcatenationNum, ElementNom)
                     SELECT x.RegleId                                                             -- Identifiant de la règle à récupérer
                         , NiveauRegle                                                            -- Identifiant du type de la règle : id du plus grand type d'élément + 1
                         , 'Règle'                                                                -- Nom du type de la règle : "Règle"
                         , theNiveau                                                              -- Niveau
                         , x.ElementId                                                            -- Identifiant du parent de la règle
                         , z.ElementTexte                                                         -- Nom du parent de la règle                 
                         , z.TypeElementId                                                        -- Identifiant du type du parent de la règle
                         , t.TypeElementlibelle                                                   -- Nom du type du parent de la règle                 
                         , CONCAT(y.ConcatenationNum, ', ', RTRIM(CAST(x.RegleId AS CHAR(6))))    -- Concaténation des id
                         , RegleTexte                                                             -- Nom de la règle
                     FROM  REGLE AS x JOIN PILE AS y ON x.ElementId = y.ElementId
                                      JOIN ELEMENT AS z ON x.ElementId = z.ElementId
                                      JOIN TYPE_ELEMENT AS t ON z.TypeElementId = t.TypeElementId 
                ;
     
                -- ----------------------------------------------
                -- Récupération des phrases
                -- ----------------------------------------------
     
                INSERT INTO PILE (ElementId, TypeElementId, TypeElementNom, Niveau, ElementParentId, ElementParentNom, TypeParentId, TypeParentNom, ConcatenationNum, ElementNom, Difficulte)
                    SELECT x.PhraseId                                                              -- Identifiant de la phrase à récupérer
                         , NiveauPhrase                                                            -- Identifiant du type de la phrase : id du type "règle" + 1
                         , 'Phrase'                                                                -- Nom du type de la phrase : "Phrase"
                         , theNiveau + 1                                                           -- Niveau atteint
                         , x.RegleId                                                               -- Identifiant de la règle parente
                         , y.RegleTexte                                                            -- Nom de la règle parente 
                         , NiveauRegle                                                             -- Identifiant du type "Règle"
                         , 'Règle'                                                                 -- Nom du type "Règle"
                         , CONCAT(z.ConcatenationNum, ', ', RTRIM(CAST(x.PhraseId AS CHAR(6))))    -- Concaténation des id
                         , x.Texte                                                                 -- Nom de la phrase
                         , t.DifficulteNiveau                                                      -- Niveau de difficulté de la phrase                     
                    FROM   PHRASE AS x JOIN REGLE AS y ON x.RegleId = y.RegleId
                                       JOIN PILE As z ON x.RegleId = z.ElementId AND z.TypeElementId = NiveauRegle    
                                       JOIN DIFFICULTE AS t ON x.DifficulteId = t.DifficulteId              
               ;
     
            END IF ;
     
        END IF;
     
    END
     
    GO
     
    DELIMITER ;
     
    -- /*
    -- --------------------------------------------------------
    -- Appel à la procédure récursive RecursonsJoyeusement
    -- --------------------------------------------------------
     
    SET @@GLOBAL.max_sp_recursion_depth = 4;  -- Pour éviter les boucles infinies...
    SET @@session.max_sp_recursion_depth = 4; 
     
    -- -------------------------------------------------------------------------------
    -- @Entree : L'élément d'identifiant ElementId = @Entree dans la table ELEMENT
    -- -------------------------------------------------------------------------------
     
    SET @Entree := 1 ;  -- L'élément d'identifiant ElementId = 1 dans la table ELEMENT (Formes et accords du verbe)
    --   SET @Entree := 5 ;  -- L'élément d'identifiant ElementId = 5 dans la table ELEMENT (Le verbe : ses formes)
     -- SET @Entree := 9 ;  -- L'élément d'identifiant ElementId = 9 dans la table ELEMENT (l'imparfait du subjonctif)
       SET @Entree := 0 ;  -- La totale
     
    SET @Amorce  := TRUE ;
     
    DELETE FROM PILE ;
     
    CALL RecursonsJoyeusement(@Amorce, @Entree);
     
    -- ----------------------------
    -- Au résultat
    -- ----------------------------
     
    SELECT * FROM PILE
    ORDER BY ElementParentId, ElementId ;
     
    SELECT x.elementId
         , x.TypeElementNom AS TypeElement
         , ConcatenationNum       
         , CASE x.TypeElementId 
               WHEN 1 THEN ElementNom 
               WHEN 2 THEN CONCAT('---- ', ElementNom)
               WHEN 3 THEN CONCAT('-------- ', ElementNom)
               WHEN 4 THEN CONCAT('------------ ', ElementNom)
            ELSE CONCAT('---------------- ', ElementNom) 
          END
           AS ElementNom       
    FROM   PILE AS x LEFT JOIN ELEMENT AS y ON x.ElementId = y.ElementId
    ORDER BY ConcatenationNum ;
     
    -- ------------------------------
    -- Sans les phrases
    -- ------------------------------
    SELECT x.elementId
         , x.TypeElementNom AS TypeElement
         , ConcatenationNum       
         , CASE x.TypeElementId 
               WHEN 1 THEN ElementNom 
               WHEN 2 THEN CONCAT('---- ', ElementNom)
               WHEN 3 THEN CONCAT('-------- ', ElementNom)
               WHEN 4 THEN CONCAT('------------ ', ElementNom)
          END
           AS ElementNom       
    FROM   PILE AS x LEFT JOIN ELEMENT AS y ON x.ElementId = y.ElementId
    WHERE   x.TypeElementId < 5
    ORDER BY ConcatenationNum ;
     
    -- */
     
    -- -----------------------------------------------------------------------
    -- Requête R1
    -- Sélection des dépendants directs des parties
    -- -----------------------------------------------------------------------
     
    SELECT  TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
          , TypeElementId, TypeElementNom, Elementid, ElementNom  
          , '' AS 'Requête R1'
    FROM    PILE
    WHERE   TypeParentId = 1 -- AND ElementParentId = 0 
    ORDER BY ElementParentId, TypeElementId -- Pour avoir dans l'ordre des types d'élément par partie
    ;
     
    SET @TypeParentId  = 1 ;
    SET @ElementParentId = 0 ;  -- signifie : ne pas tenir compte (on est au niveau racine)
     
    -- ---------------------------------------------------------------------------------
    -- Requête R2
    -- Raoul a choisi "Le verbe, ses formes" (TypeElementId = 2, ElementId = 5).
    -- Pour avoir la descendance directe : TypeParentId = 2 et ElementParentId = 5.
    -- ---------------------------------------------------------------------------------
     
    SELECT  TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
          , TypeElementId, TypeElementNom, Elementid, ElementNom
          , Difficulte, RAND() as Alea      
          , '' AS 'Requête R2'
    FROM   PILE
    WHERE  TypeParentId = 2 AND ElementParentId = 5 -- sous-partie 5, le verbe, ses formes
     -- WHERE  TypeParentId = 4 AND ElementParentId = 9 -- sous-partie 9
    ORDER BY ElementParentId, TypeElementId, Alea -- Dans l'ordre des types d'élément par partie, et aléatoire pour le dernier niveau
    ;
     
     
    -- --------------------------------------------------------
    -- Appel à la procédure récursive RaoulNavigue
    -- --------------------------------------------------------
     
    SET @TypeParentId  = 2 ;          -- 'sous-partie'
    SET @ElementParentId = 5 ;        -- 'le verbe, ses formes'
    SET @Difficulte = 2 ;             -- 'niveau de difficulté (0 si pas de filtre)'
     
     
    SET @TypeParentId  = 4 ;
    SET @ElementParentId = 9 ;
    SET @Difficulte = 2 ;
    -- SET @Difficulte = 0 ;
     
    CALL RaoulNavigue(@TypeParentId, @ElementParentId, @Difficulte) ;
     
    SELECT * FROM PROPOSITION ;
    -- --------------------------------------------------------------------------------------
    -- Requête R3
    -- Raoul a choisi "L'imparfait du subjonctif" (TypeElementId = 3 et ElementId = 9)
    -- Pour avoir la descendance directe : TypeParentId = 3 et ElementParentId = 9.
    -- --------------------------------------------------------------------------------------
     
    SELECT  TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
          , TypeElementId, TypeElementNom
          , Elementid
          , ElementNom
          , Difficulte
          , '' AS 'Requête R3'
    FROM   PILE
    WHERE  TypeParentId = 3 AND ElementParentId = 9
    ORDER BY ElementParentId, TypeElementId  -- Pour avoir dans l'ordre des types d'élément par partie
    ;
     
    SET @TypeParentId  = 3 ;
    SET @ElementParentId = 9 ;  
    SET @Difficulte = 2 ;
    ;
     
    CALL RaoulNavigue(@TypeParentId, @ElementParentId, @Difficulte) ;
     
    SELECT * FROM PROPOSITION ;
     
     
    -- --------------------------------------------------------------------------------------
    -- Requête R4
    -- Raoul a choisi "La 3e personne du pluriel" (TypeElementId = 4 et ElementId = 6)
    -- Pour avoir la descendance directe : TypeParentId = 4 et ElementParentId = 6.
    -- --------------------------------------------------------------------------------------
     
    SELECT  TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
          , TypeElementId, TypeElementNom, Elementid, ElementNom
          , Difficulte      
          , '' AS 'Requête R4'
    FROM    PILE
    WHERE   TypeParentId = 4 AND ElementParentId = 6
    ORDER BY ElementParentId, TypeElementId
    ;
     
    SET @TypeParentId  = 4 ;
    SET @ElementParentId = 6 ;  
    SET @Difficulte = 2 ;
     
    -- CALL RaoulNavigue(@TypeParentId, @ElementParentId, @Difficulte) ;
    CALL RaoulNavigue(4, 6, 2) ;
     
    SELECT Numeroligne, ElementNom FROM PROPOSITION ORDER BY NumeroLigne ;
     
    
    M'enfin...

  2. #62
    Membre actif
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    388
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations forums :
    Inscription : Janvier 2010
    Messages : 388
    Points : 209
    Points
    209
    Par défaut
    Bonsoir fsmrel,

    Merci. J'ai testé la procédure RaoulNavigue avec un jeu d'essai restreint s'agissant de la table PHRASE :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    INSERT INTO `phrase` (`RegleId`, `PhraseId`, `DifficulteId`, `Position`, `Texte`) VALUES
    (1, 1, 1, 5, 'Le petit chat est morts'),
    (1, 2, 2, 5, 'Il a un petit soucis'),
    (1, 3, 1, 3, 'Des yeux marrons'),
    (1, 4, 2, 4, 'Il est huit heure'),
    (1, 5, 3, 0, 'Huit cent deux kilos'),
    (3, 1, 2, 0, 'Je vais à Paris'),
    (3, 2, 2, 0, 'Pierre a faim'),
    (3, 3, 4, 0, 'Ce crayon est a moi'),
    (4, 1, 1, 2, 'Il et fort et agile'),
    (4, 2, 1, 0, 'Elle est grande'),
    (4, 3, 4, 0, 'Il aime le cuissot de chevreuil'),
    (4, 4, 4, 5, 'Il aime aussi le cuissot de veau'),
    (4, 5, 3, 0, 'C''est une imbécillité'),
    (6, 1, 4, 0, 'Qu''il aimât cela !'),
    (6, 2, 3, 2, 'Qu''il n''aimat pas cela !');
    Extrait de la table pile :

    Nom : Capture3.PNG
Affichages : 141
Taille : 8,1 Ko

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    CALL RaoulNavigue(4,3,2) ;
    SELECT * FROM PROPOSITION;
    Résultat :

    Nom : Capture1.PNG
Affichages : 152
Taille : 5,3 Ko
    Ce résultat est conforme : affiche les phrases de difficulté 2 dans un ordre aléatoire.

    Autre test :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    CALL RaoulNavigue(4,3,0) ;
    SELECT * FROM PROPOSITION;
    Cette fois-ci, je souhaite obtenir l'affichage des phrases, toujours dans un ordre aléatoire, mais tout niveau de difficulté confondu :

    Résultat :

    Nom : Capture2.PNG
Affichages : 139
Taille : 6,4 Ko
    Toutes les phrases attendues s'affichent mais je perds l'ordre aléatoire. Voyez-vous comment modifier le code de la procédure pour conserver l'ordre aléatoire dans le cas de l'affichage de phrases tout niveau de difficulté confondu ?

  3. #63
    Expert éminent sénior
    Avatar de fsmrel
    Homme Profil pro
    Spécialiste en bases de données
    Inscrit en
    Septembre 2006
    Messages
    8 113
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Spécialiste en bases de données
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2006
    Messages : 8 113
    Points : 31 588
    Points
    31 588
    Billets dans le blog
    16
    Par défaut
    Bonsoir almoha,


    Citation Envoyé par almoha
    Cette fois-ci, je souhaite obtenir l'affichage des phrases, toujours dans un ordre aléatoire, mais tout niveau de difficulté confondu
    D’accord. J’avais pensé que l’ordre aléatoire ne valait que lorsque Raoul choisissait un niveau en particulier. Je modifie donc la procédure RaoulNavigue (modifs en bleu) :



    
    CREATE PROCEDURE RaoulNavigue
    (
       IN TypeParentChoisiId INT, ParentChoisiId INT, DifficulteChoisie INT
    )
    
    BEGIN
    
    DECLARE theNumeroLigne INT ;
    
    -- Pour réutiliser la table, on commence par virer ce qui a déjà été traité
    
    DELETE FROM PROPOSITION ;
     
    IF TypeParentChoisiId < 4 THEN 
        INSERT INTO PROPOSITION
                   (TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom)  
            SELECT  TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom 
            FROM    PILE
            WHERE   TypeParentId = TypeParentChoisiId AND ElementParentId = ParentChoisiId 
            ORDER BY ElementParentId, TypeElementId ; -- Pour avoir dans l'ordre des types d'élément par partie
    ELSE
                    -- RAND() : pour rendre aléatoire l'ordre des phrases dans la table
        INSERT INTO PROPOSITION
                   (Alea, TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom)    
            SELECT  RAND() AS Alea, TypeParentId, TypeParentNom, ElementParentId, ElementParentNom
                  , TypeElementId, TypeElementNom, Elementid, ElementNom         
            FROM    PILE
            WHERE   TypeParentId = TypeParentChoisiId AND ElementParentId = ParentChoisiId
              AND   (Difficulte = DifficulteChoisie OR DifficulteChoisie = 0)
              AND   TypeElementId = 5                      -- 5 : l'élément est de type phrase
            ORDER BY Alea ;
    
    END IF ;
    
    -- Comme MySQL ne réinitialise pas à 1 l’auto-incrémentation après delete, on s’en charge
    
    SET theNumeroLigne = (SELECT COALESCE(MIN(NumeroLigne), 0)  FROM PROPOSITION) ;
    
    UPDATE PROPOSITION 
        SET NumeroLigne = NumeroLigne + 1 - theNumeroLigne ;
    
    END 
    
    GO
    
    

  4. #64
    Expert éminent sénior
    Avatar de fsmrel
    Homme Profil pro
    Spécialiste en bases de données
    Inscrit en
    Septembre 2006
    Messages
    8 113
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Spécialiste en bases de données
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2006
    Messages : 8 113
    Points : 31 588
    Points
    31 588
    Billets dans le blog
    16
    Par défaut
    Près de 1000 candidats pour vous...

    Faut-il en rire ou en pleurer ? (Le 31 octobre 1994, Jacques Lacant raconte...)

    http://www.fsmwarden.com/mp3/Lacant_..._pharmacie.mp3

  5. #65
    Membre actif
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    388
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations forums :
    Inscription : Janvier 2010
    Messages : 388
    Points : 209
    Points
    209
    Par défaut
    Bonsoir fsmrel,

    D’accord. J’avais pensé que l’ordre aléatoire ne valait que lorsque Raoul choisissait un niveau en particulier. Je modifie donc la procédure RaoulNavigue (modifs en bleu) :
    C'est parfait, cela fonctionne comme attendu . Je vais continuer mes différents tests.

    Faut-il en rire ou en pleurer ? (Le 31 octobre 1994, Jacques Lacant raconte...)
    Merci pour ce lien. Cette chronique est édifiante et conforte malheureusement mon avis sur le sujet . Dire que la situation a très certainement empiré de nos jours...

  6. #66
    Expert éminent sénior
    Avatar de fsmrel
    Homme Profil pro
    Spécialiste en bases de données
    Inscrit en
    Septembre 2006
    Messages
    8 113
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Spécialiste en bases de données
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2006
    Messages : 8 113
    Points : 31 588
    Points
    31 588
    Billets dans le blog
    16
    Par défaut
    Bonsoir almoha,



    Citation Envoyé par almoha
    C'est parfait, cela fonctionne comme attendu . Je vais continuer mes différents tests.
    Ouf ! Bon je reste à l'écoute...

Discussions similaires

  1. [OL-2007] Classer ses mails en catégories, sous catégories
    Par Dae_mon dans le forum VBA Outlook
    Réponses: 2
    Dernier message: 28/02/2014, 14h04
  2. Réponses: 11
    Dernier message: 24/09/2013, 11h06
  3. Réponses: 10
    Dernier message: 21/10/2009, 15h17
  4. [MySQL] [CMS] Gestion de Catégories/Sous catégories
    Par aenema dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 31/08/2008, 09h25
  5. Réponses: 17
    Dernier message: 07/09/2007, 08h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo