Basta mettere nel db un campo id contatore non duplicabile