title: Database design to store notifications to users
body: <p>I'm working on a literature community website. (<a href="http://s159.photobucket.com/albums/t146/epochcoyote/?action=view&amp;current=e7c7465f.png" rel="noreferrer">screenshot</a>) And I'm trying to figure out how to notify users when someone comments on something they posted to the site, when someone they are watching submissions a new literature peice, etc. </p>
  
  <p>I'm trying to figure out how to structure the database to store this information. I've come up with two possible ideas. </p>
  
  <ol>
  <li><p>Store a link to the notifiable object, a field describing the type of action (new, update, etc) that the user is being notified of. This makes for complex display code but it means I can change how notifications work rather easily. This also increase the data I need to pull from the database unless I use a cache field to dump a hash of relevant attributes into the table. </p>
  
  <ul>
  <li>notifiable_type</li>
  <li>notifiable_id</li>
  <li>user_id</li>
  <li>action </li>
  <li>notifiable_cache (optional, stores a hash of selected attributes from notifiable object)</li>
  </ul></li>
  <li><p>Treat the notifications like email and just save them to the database with a subject and message. This results in a simple view but a complex model and prevents me from easily changing how notifications work. </p>
  
  <ul>
  <li>user_id</li>
  <li>title</li>
  <li>message</li>
  </ul></li>
  </ol>
  
  <p>I'm looking for other ideas and comments on the two I listed above. </p>