Ok, I am not happy about introducing materialization into the schema this early on. Aggregating all votes into a rating is something that can and should be done at the database level. You don't have to `sort` in Python either, this can be done entirely at the database. I can't help you with SQL Alchemy, but I can help you write the SQL that would do that.

Introducing `rating` is introducing redundancy which will have to be maintained, and I can guarantee will go wrong at some point in the future. Keep things simple, and optimize once it's apparent that something really is a problem.