title: MySQL - Multiple foreign keys, that are only valid on individual check constraints
body: <p>Title says pretty much what I need but I want to see how I can take two foreign key constraints from a table, and two check constraints and associate one check constraint, while associating the second check constraint with the second foreign key constraint.</p>
  
  <p>Example, I have two 3 tables,  <code>item</code>, <code>action</code>, <code>risk</code>.  <code>Item</code> references <code>action</code> or <code>risk</code>, by <em><code>itemid</code></em> <strong>only I want conditional references on more than one foreign key with each foreign key having one unique check constraint</strong>.</p>
  
  <p>I will use <em>itemtype</em> ( <em>'Action'</em> or <em>'Risk'</em>) in my check constraint to determine what table I am referencing.   </p>
  
  <p>Here is my command:</p>
  
  <pre><code>ALTER TABLE `projectaim`.`items`  
                ADD CONSTRAINT `fk_item_risk` FOREIGN KEY (`ItemID`) REFERENCES `projectaim`.`risks`(`RiskID`)
  ADD CONSTRAINT ck_item_type CHECK (itemtype = 'Risk') 
  </code></pre>
  
  <p>Is this at all possible in MySQL?</p>