title: designing a badge system, where to fire business logic? In code or stored procedures? or both?
body: <p>If you were to build a badge system similiar to how SO does it, would you put the logic/business layer in the database directly (via stored procedure, scheduled sql jobs) or put it in the server side?</p>
  
  <p>From what I can think of, you have to:</p>
  
  <ol>
  <li>list badges that pertain to the current user action</li>
  <li>check if the user has a badge already or not</li>
  <li>insert badge for user </li>
  </ol>
  
  <p><b>Potential options</b></p>
  
  <ol>
  <li>business logic in the web application that calls stored procedures etc.</li>
  <li>stored procedures ONLY</li>
  <li>sql server job that runs every x minutes</li>
  <li>windows service that runs every x minutes</li>
  </ol>
  
  <p>Would a combination of these be required? I think it would since some badges are based on milestones for a given question, maybe a batch job is better?</p>
  
  <p><b>Update</b></p>
  
  <p>A system where you can modify the badge system, then re-run the entire badge linking for everyone would be even better.  i.e. say you change the logic for some badges, now you have to re-apply it to all the questions/answers/votes/etc.</p>
  
  <p><b>interesting problem to solve!!</b></p>