title: How to make INSERT fail on a table that has foreign key to another table when the row contains some specific value?
body: <p>I'm sorry if the title is confusing (which it is, likely). Let me give you an example similar to my case.</p>
  
  <p>So for example I have <code>users</code> table with fields <code>id</code>, <code>user_type</code>, and <code>name</code>. </p>
  
  <p>Another table is <code>videos</code> with fields <code>id</code>, <code>title</code>, and <code>user_id</code> referencing to <code>users.id</code>. I want <code>INSERT</code> to <code>videos</code> to fail when <code>videos.user_id</code> references <code>users</code> row that the value of <code>user_type</code> is 'a', for example.</p>