title: Database and relationship design when subclassing a model
body: <p>I have a model "Task" which will HABTM many "TaskTargets".</p>
  
  <p>When it comes to TaskTargets however, I'm writing the base TaskTarget class which is abstract (as much as can be in Rails).  TaskTarget will be subclassed by various different conceptualizations of anything that can be the target of a task.  So say, software subsystem, customer site, bathroom, etc...</p>
  
  <p>The design of the classes here is fairly straightforward, but where I'm hitting a snag is in how I will relate it all together and how I will have rails manipulate those relationships.</p>
  
  <p>My first thought is that I will have a TaskTarget table which will contain the basic common fields (name, description...).  It will then also have a polymorphic relationship out to a table specific to the type of data the implementing class wraps.
  This implies that the data for one instance of a class implementing TaskTarget will be found in two tables.</p>
  
  <p>The second approach is to create a polymorphic HABTM relationship between Task and subclasses of TaskTarget which I thought I could reuse the table name TaskTarget for the join table.</p>
  
  <p>Option #2 I suspect is the most robust, but maybe I'm missing something.  Thanks for any help and of course I'm really just asking to make sure I get it done right, once!</p>