I am working on a Facebook-alike app (ASP.NET MVC). Based on the number of likes on an entry, there are different badges to be assigned: On the 5th like, Badge A should be assigned, on the 10th like, Badge B should be assigned, and so forth.
However, I need to query the database in every user like to see if there is any suitable badge to assign. For example, in the 4th like event, I need to check if there is a badge that requires 4 likes, and I need to assign it.
When a liking occurs, in the application code I need to check if the entry has 4 likes, and assign the badge with db.BadgeAssignments.Add(new badge info goes here)
when a liking occurs.
I wonder if it is better I do this automatically using the SQL Database Management Studio? When an entry receives the 5th like, etc., a new record can be added to the BadgeAssignment table. Does this make sense? This could be better in terms of performance, but I feel like it will be more tedious.
What would be the recommended approach in this?