title: Is it possible to constrain a table to have a value in only one of a set of columns
body: <p>I have a table which needs to link one of three seperate tables, but it should only link to one of them, e.g.</p>
  
  <pre><code>Main_Table
  id UNIQUEIDENTIFIER
  t1_id UNIQUEIDENTIFIER
  t2_id INT
  t3_id INT
  
  T1
  id UNIQUEIDENTIFIER
  name VARCHAR(255)
  
  T2
  id INT
  name VARCHAR(255)
  
  T3
  id INT
  name VARCHAR(255)
  </code></pre>
  
  <p>Is it possible to have a constraint whereby only one of t1, t2 or t3 is not null at any one time?</p>
  
  <p>Is this just bad design? If so, what suggestions would you make for the design?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I've been asked to elaborate the reasons behind this particular design.</p>
  
  <p>Main_Table is attempting to be a payer table, which could reference either an individual user (T1), a group of individual users (T2), or a group of groups (T3).</p>
  
  <p>This is a database design I've inherited, and it isn't really subject to change unfortunately.</p>
  
  <p>My biggest problem is that I need to associate between different types, so a type field won't work here as the indexes are different.</p>