title: Hacker News rails clone: advice on modeling relationship between links, comments and votes
body: <p><em>I'm loving Rails but we just started dating.</em></p>
  
  <p>A user can vote on both links and comments.  In addition to primary key and timestamp, I currently have the following attributes defined for these models:</p>
  
  <ul>
  <li><strong>Link</strong>    url, headline, submitter_id, score</li>
  <li><strong>Comment</strong> content, commenter_id, score, link_id, parent_comment_id</li>
  <li><strong>Vote</strong>    id, voter_id, link_id, direction</li>
  </ul>
  
  <p>I just added the Comment Model and thinking through how to integrate it with votes.  Some options:</p>
  
  <ol>
  <li>Collapse links and comments into a single "Item" model, and map votes to the generic item_id</li>
  <li>Have two vote tables, one for comments, one for links</li>
  <li>Add comment_id column to existing Vote table</li>
  </ol>
  
  <p>Not sure what's best.  #1 and #3 introduce dual-purpose tables, i.e. there are certain columns in a table that are only relevant to subsets of rows within that table.  #2 avoids this problem, but seems redundant and silly.</p>
  
  <p>Is the tradeoff inevitable or am I not seeing the golden path?  What would you recommend?  And if you happen to know of a rails repository on github that handles a similar situation, I'd really appreciate a link!</p>