Reputation: 11159
I have a simple blog webapp where users may vote.
What would be the advantages of having a single integer that goes up or down(should negative numbers be allowed?), or having a likes and dislikes counts that only go up.
Which is more flexible, which is more optimal?
Upvotes: 1
Views: 118
Reputation: 887
Tracking both the number of likes and dislikes allows viewers to see how many people liked/disliked the post, rather than just the difference of the two numbers. That gives you the ability to illustrate how many people have seen the post and bothered to vote.
If that is important to you, it may be worth it to keep track of the extra number.
Upvotes: 2
Reputation: 1330
To have two counters on the DB side (for likes and dislikes) is more flexible and allows you to give more choices in the future. But it's a bit more expensive than only one.
Upvotes: 2