title: How to implement a link that can get bonus for 5 times by different people on a Social Network?
body: <p>Some social games on Facebook let user publish a link to their feed to say, "Click here to get bonus gold coins -- limited to the first 5 people".</p>
  
  <p>How can we generate such a link?</p>
  
  <p>The link shouldn't be easily "generated" by any people as a cheating method.</p>
  
  <p>Also, what database table(s) should be added to handle:</p>
  
  <p>1) the bonus can be claimed up to 5 times<br>
  2) must be claimed by different people</p>
  
  <p>(each person has a unique numeric ID on social network platform such as Facebook)</p>
  
  <p>?</p>
  
  <p><strong>Update:</strong> the way I was thinking of is to get the next primary ID (an integer index) in the Prize table, and md5 it with some secret key to get a "prize code", and make sure it is not already in the "PrizeClaimed" table -- if already exist, just use the next primary ID (by adding a record and recalculate md5 until a unique one is found).  This PrizeClaim table is a junction table for prize_code and user_id, so one prize can be claimed by multiple people, and one person can claim multiple prizes.  If when a person clicks on the link, we add the record of the prize_code and user_id into the table -- but only if the number of records obtained by the matching the prize_code is 4 or less.  If 5 already, then just report "too late -- claimed by all people".  I wonder how this method is, is there any loophole, improvement, or other ways to implement it?</p>
  
  <p>(for example, the Prize table is just a table for getting the ID, and it stores nothing else.  Maybe we can use the current timestamp with microseconds plus a random number to do the md5, and if prize_code already exist, just repeat again.  In this case we can forget about the Prize table.)</p>