title: Data structure: Link a table to one of several other
body: <p>I have a database table <code>SavedData</code> which contains a field <code>type_data</code>. I need to link that table to one of the tables <code>SpecificData1</code>, <code>SpecificData2</code> and <code>SpecificData3</code>, depending on what is in the <code>type_data</code> field.</p>
  
  <p>I have thought of a few solutions, but none of them looks great... :</p>
  
  <ol>
  <li><p><strike>Have 3 fields in <code>SavedData</code> called <code>specificdata1_id</code>,  <code>specificdata2_id</code> and  <code>specificdata3_id</code>, and one of them is set, with the 2 others <code>NULL</code>. I can then use the specific data for which the id is not null.</strike> After some reading, I've seen this one is really bad, which is understandable.</p></li>
  <li><p>Have 1 field in <code>SavedData</code> called <code>specificdata_id</code>, and depending on the <code>type_data</code> I know in which table I need to look for that id.</p></li>
  <li><p>Put all the fields from the 3 specific data tables in the <code>SavedData</code> table and use only the data that I need depending on the value of <code>type_data</code>.</p></li>
  </ol>
  
  <p>What would be the best solution ? Is there another one that could solve my problem ?</p>