title: MySQL foreign key constraints, cascade delete
body: <p>I want to use foreign keys to keep the integrity and avoid orphans (I already use innoDB).</p>
  
  <p>How do I make a SQL statment that DELETE ON CASCADE?</p>
  
  <p>If I delete a category then how do I make sure that it would not delete products that also are related to other categories.</p>
  
  <p>The pivot table "categories_products" creates a many-to-many relationship between the two other tables.</p>
  
  <pre><code>categories
  - id (INT)
  - name (VARCHAR 255)
  
  products
  - id
  - name
  - price
  
  categories_products
  - categories_id
  - products_id
  </code></pre>