What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

I have trouble understanding this. If Stack Overflow can detect whether a user has already upvoted a question, does it have a flag for each and every post in a table, and whether a user has upvoted it.

If not how does it detect if a user is 'spamming' votes then?

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

Have a look at the schema on the Data Explorer and you can see the Votes table:

Votes
-----
Id
PostId
VoteTypeId
UserId
CreationDate
BountyAmount

So they just record each post/user/vote type combination as required.

Obviously there's going to be some logic in there to prevent an single user having both an up and down vote on the same post, or that only the question owner can cast a "accepted answer" vote on their answers, and so on.

share|improve this answer
    
This is an incredible amount of data to be stored –  liamzebedee Sep 20 '11 at 10:46
2  
@Liam maybe, but it's the bare minimum, isn't it? –  Pëkka Sep 20 '11 at 10:50
1  
@Liam Disk space is fairly cheap –  Justin Sep 20 '11 at 10:54
    
I guess, as the internet expands, and electronics according to Moores law, it will all become smaller, more efficient. –  liamzebedee Sep 20 '11 at 11:22
add comment

Yes, it will have. However, it would also seem that they cache the score of a question in the post table for performance reasons.

I also believe that this cached value is recalculated periodically.

(Pseudo):

Vote

  • user_id
  • post_id
  • amount

Post

  • id
  • score /* Cached value of SELECT SUM(amount) FROM Vote WHERE post_id = id */
share|improve this answer
1  
Here's another test for push notifications. Did you get it? –  Geoff Dalgas Jun 11 at 15:18
    
Certainly did this time :). Awesome! –  Matt Jun 11 at 15:19
add comment

IN SO database, there is a Votes table which contains PostId, UserId, and VoteTypeId columns. VoteTypeId=2 is for UpVotes and 3 is for DownVotes. So I guess you are right that it does have a flag for each and every post.

share|improve this answer
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .