title: Foreign key constraints: When to use ON UPDATE and ON DELETE
body: <p>I'm designing my database schema using MySQL Workbench, which is pretty cool because you can do diagrams and it converts them :P</p>
  
  <p>Anyways, I've decided to use InnoDB because of it's Foreign Key support. One thing I noticed though is that it allows you to set On Update and on Delete options for foreign keys. Can someone explain where "Restrict", "Cascade" and set null could be used in a simple example?</p>
  
  <p>For example, say I have a <code>user</code> table which includes a <code>userID</code>. And say I have a message table <code>message</code> which is a many-to-many which has 2 foreign keys (which reference the same primary key, <code>userID</code> in the <code>user</code> table). Is setting the On Update and On Delete options any useful in this case? If so, which one do I choose? If this isn't a good example, could you please come up with a good example to illustrate how these could be useful?</p>
  
  <p>Thanks</p>