title: How to model a mutually exclusive relationship in SQL Server
body: <p>I have to add functionality to an existing application and I've run into a data situation that I'm not sure how to model. I am being restricted to the creation of new tables and code. If I need to alter the existing structure I think my client may reject the proposal.. although if its the only way to get it right this is what I will have to do.</p>
  
  <p>I have an Item table that can me link to any number of tables, and these tables may increase over time. The Item can only me linked to one other table, but the record in the other table may have many items linked to it.</p>
  
  <p>Examples of the tables/entities being linked to are <code>Person</code>, <code>Vehicle</code>, <code>Building</code>, <code>Office</code>. These are all separate tables.</p>
  
  <p>Example of Items are <code>Pen</code>, <code>Stapler</code>, <code>Cushion</code>, <code>Tyre</code>, <code>A4 Paper</code>, <code>Plastic Bag</code>, <code>Poster</code>, <code>Decoration"</code></p>
  
  <p>For instance a <code>Poster</code> may be allocated to a <code>Person</code> or <code>Office</code> or <code>Building</code>. In the future if they add a <code>Conference Room</code> table it may also be added to that.</p>
  
  <p>My intital thoughts are:</p>
  
  <pre><code>Item
  {
    ID,
    Name
  }
  
  LinkedItem
  {
    ItemID,
    LinkedToTableName,
    LinkedToID
  }
  </code></pre>
  
  <p>The <code>LinkedToTableName</code> field will then allow me to identify the correct table to link to in my code. </p>
  
  <p>I'm not overly happy with this solution, but I can't quite think of anything else. Please help! :)</p>
  
  <p>Thanks!</p>