title: Prestashop category-product association table allowing duplicates?
body: <p>The table <code>ps_category_product</code> in PrestaShop has the following structure</p>
  
  <pre><code> # Obtained using SHOW CREATE TABLE `ps_category_product`
   CREATE TABLE `ps_category_product` (
     `id_category` int(10) unsigned NOT NULL,
     `id_product` int(10) unsigned NOT NULL,
     `position` int(10) unsigned NOT NULL DEFAULT '0',
     KEY `category_product_index` (`id_category`,`id_product`),
     KEY `id_product` (`id_product`)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>For me is not very clear, but it seems that the fields <code>id_category</code> and <code>id_product</code> should be unique among the table, but for some reason MySQL allows me to insert duplicates:</p>
  
  <pre><code>mysql&gt; select * from ps_category_product limit 10;
  +-------------+------------+----------+
  | id_category | id_product | position |
  +-------------+------------+----------+
  |          11 |          1 |        1 |
  |          11 |          2 |        1 |
  |          11 |          3 |        1 |
  |          11 |          4 |        1 |
  |          11 |          5 |        1 |
  |          11 |          6 |        1 |
  |          11 |          7 |        1 |
  |          11 |          8 |        1 |
  |          11 |          9 |        1 |
  |          11 |         10 |        1 |
  +-------------+------------+----------+
  10 rows in set (0.00 sec)
  
  mysql&gt; INSERT INTO `ps_category_product` VALUES(11, 1, 1);
  Query OK, 1 row affected (0.05 sec)
  </code></pre>
  
  <p>How can I prevent this from happening?</p>
  
  <h2>Later edit</h2>
  
  <p>It was a bug in prestashop. Take a look at <a href="http://forge.prestashop.com/browse/PSCFI-4397" rel="nofollow">http://forge.prestashop.com/browse/PSCFI-4397</a></p>