title: How can I avoid reputation increasing when that vote didn't decrease the reputation?
body: <p>I'm working on a project and I've faced with a logical problem. </p>
  
  <p>Our project is a question and answer website. Something exactly like StackOverflow. The problem is about <em>voting</em> system. All policies are exactly like SO <em>(each downvote <code>-2</code> rep, each upvote on question <code>+5</code>, on answer <code>+10</code> and etc)</em></p>
  
  <p>Ok, assume this: A user has <code>1</code> rep, and he asks a question. His question earns 1 downvote. My trigger would handle the reputations:</p>
  
  <pre><code>UPDATE users SET reputation = GREATEST(reputation - 2, 1) WHERE id = new.user_id
  </code></pre>
  
  <p>So the number of his reputation will be still <code>1</code>. Now if that downvote be taken back, this trigger will increase his reputations:</p>
  
  <pre><code>UPDATE users SET reputation = reputation + 2 WHERE id = new.user_id
  </code></pre>
  
  <p>So the number of his reputation will be <code>3</code> <em>(which shouldn't be)</em>. It's a logical problem. Is there any idea how can I handle that? Or how SO handles that?</p>