This is not SO Meta question. I am using SO only as example.
In StackoverFlow each answer, each comment, each question, each vote has a effect which produces a badge at some point of time. I mean after every action a list of queries are tested.
E.g. If Mr.A up votes Mr.B Answer. So we have to check is this Mr.B's answer upvoted 100 times so give the Mr.B a badge , Has Mr.A upvoted 100th time so give him a badge.
It means I have to run at least 100 queries/IfElse for each action.
Now my real life example is I have an application where I receive online data from an attendance machine. When a user shows his card to machine. I receive this and store it as a record. Now based on this record I have multiple calculations.i.e Is he late. Is he late for continues 3 days. Is he in a right shift(Day shift/Night Shift). Is today holiday. Is this a overtime. Is he early.......etc.,etc.,etc.
What is the best strategy for this kind of requirements.
Update: Can SO team guide us on this?