Avoid duplicate taggings via programming and SQL contraints