score is cached beside the vote rows
The honest number is count(upvotes) - count(downvotes) over the votes table, and on a busy post that is a scan nobody wants on every page render. posts keeps score, upvote_count and comment_count so a listing sorts on an indexed column. The price is that a vote write must touch two places, and the counts can drift — which is why they are periodically recomputed rather than trusted forever.