title: Achievements / Badges system
body: <p>I have been browsing this site for the answer but I'm still a little unsure how to plan a similar system in its database structure and implementation.</p>
  
  <p>In PHP and MySQL it would be clear that some achievements are earned immediately (when a specialized action is taken, in SO case: Filled out all profile fields), although I know SO updates and assigns badges after a certain amount of time. With so many users &amp; badges wouldn't this create performance problems (in terms of scale: high number of both users &amp; badges).</p>
  
  <p>So the database structure I assume would something as simple as:</p>
  
  <pre><code>Badges     |    Badges_User      |    User
  ----------------------------------------------
  bd_id      |    bd_id            |  user_id
  bd_name    |    user_id          |  etc
  bd_desc    |    assigned(bool)   |  
             |    assigned_at      |
  </code></pre>
  
  <p>But as some people have said it would be better to have an incremental style approach so a user who has 1,000,000 forum posts wont slow any function down.</p>
  
  <p>Would it then be another table for badges that could be incremental or just a 'progress' field in the badges_user table above?</p>
  
  <p>Thanks for reading and please focus on the scalability of the desired system (like SO thousands of users and 20 to 40 badges).</p>
  
  <p>EDIT: to some iron out some confusion I had assigned_at as a Date/Time, the criteria for awarding the badge would be best placed inside prepared queries/functions for each badge wouldn't it? (better flexibility)</p>