title: foreign key from one column to two columns of different table by condition
body: <p>I have tree tables MySQL:</p>
  
  <p>articles table contains:</p>
  
  <pre><code>id int
  title varchar(255)
  ...
  </code></pre>
  
  <p>news table contains:</p>
  
  <pre><code>id int
  title varchar(255)
  ...
  </code></pre>
  
  <p>comments table contains:</p>
  
  <pre><code>id int
  content text
  type tinyint(1)  //this column holds 0 if this comment for news and holds 1 for article
  fid  int         // this column holds id of article or news 
  </code></pre>
  
  <p>how can I make foreign key from comments table to articles and news. 
  I mean how can implement this in MySQL query:</p>
  
  <pre><code>if type=0 then
   FOREIGN KEY (fid) REFERENCES news(id)
  
  if type=1 then
   FOREIGN KEY (fid) REFERENCES articles(id)
  </code></pre>