Bonjour,
Après avoir cherché dans de nombreuses discussions, je me permets d'exposer mon problème.
J'ai réalisé via MySQLWorkbench une BDD. Lors de l'export sur phpmyadmin, toutes les requêtes sont bonnes, incluant les clés primaires et clés étrangères.
Cependant sur ma table 'ligne_commande' les relations sont bien prises en compte, voici la requête : l'objectif étant qu'une ligne de commande renvoie à un id produit, de la table Produit.
Or, j'ai réalisée la même requête pour la table Panierclient, qui doit renvoyer à l' idligne_commande mais celle-ci ne fonctionne pas. Voici la seconde requête :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 CREATE TABLE IF NOT EXISTS `caddie`.`ligne_commande` ( `idligne_commande` INT NOT NULL AUTO_INCREMENT, `quantite` VARCHAR(45) NOT NULL, `session_id` VARCHAR(45) NOT NULL, `products_id` INT NOT NULL, PRIMARY KEY (`idligne_commande`, `session_id`, `products_id`), INDEX `fk_ligne_commande_products1_idx` (`products_id` ASC), CONSTRAINT `fk_ligne_commande_products1` FOREIGN KEY (`products_id`) REFERENCES `caddie`.`products` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB;
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
18
19
20
21 -- Table `caddie`.`panierclient` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `caddie`.`panierclient` ( `idpanier` INT NOT NULL AUTO_INCREMENT, `datepanier` DATETIME NOT NULL, `prix_total_panier` FLOAT NOT NULL, `quantite` INT NOT NULL, `poids_total` VARCHAR(45) NOT NULL, `idproduit_respectif` VARCHAR(45) NOT NULL, `quantite_respective` VARCHAR(45) NOT NULL, `ligne_commande_idligne_commande` INT NOT NULL, `ligne_commande_session_id` VARCHAR(45) NOT NULL, `ligne_commande_products_id` INT NOT NULL, PRIMARY KEY (`idpanier`, `ligne_commande_idligne_commande`, `ligne_commande_session_id`, `ligne_commande_products_id`), INDEX `fk_panierclient_ligne_commande1_idx` (`ligne_commande_idligne_commande` ASC, `ligne_commande_session_id` ASC, `ligne_commande_products_id` ASC), CONSTRAINT `fk_panierclient_ligne_commande1` FOREIGN KEY (`ligne_commande_idligne_commande` , `ligne_commande_session_id` , `ligne_commande_products_id`) REFERENCES `caddie`.`ligne_commande` (`idligne_commande` , `session_id` , `products_id`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB;
Malgré des heures à chercher, je n'arrive pas à trouver mon erreur et à la modifier.
Un regard extérieur me serait précieux.
Merci à vous.
Partager