title: How to make foreign key
body: <p>i'm trying to make an sql create table but I fail to make a foreign key.</p>
  
  <p>My code :</p>
  
  <pre><code>Db::getInstance()-&gt;execute('
  
        CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'sondage`(
        `id` int(6) NOT NULL AUTO_INCREMENT,
        `question` varchar(60) NOT NULL,
        PRIMARY KEY(`id`)) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8')
  
  || !Db::getInstance()-&gt;execute('
  
        CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'sondage_reponse`(
        `id` int(6) NOT NULL AUTO_INCREMENT,
        `champ1` int(4) NOT NULL,
        `champ2` int(4) NOT NULL,
        `champ3` int(4) NOT NULL,
        PRIMARY KEY(`id`)) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8')
  
  
  || !Db::getInstance()-&gt;execute('
  
   INSERT INTO '._DB_PREFIX_.'sondage_reponse (champ1,champ2,champ3)
   VALUES (0,0,0)')
  </code></pre>
  
  <p>I want to make id from "sondage" foreign key in "sondage_reponse".I've tryed :</p>
  
  <pre><code> ALTER TABLE ps_sondage_reponse
              ADD FOREIGN KEY fk_id_sdg(id)
              REFERENCES sondage(id)')
  </code></pre>
  
  <p>But Prestashop can't add the foreign key.</p>
  
  <p>Thx</p>