cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kasper Middelboe Petersen <>
Subject Datamodel for a highscore list
Date Wed, 22 Jan 2014 17:44:20 GMT

I'm a little worried about the data model I have come up with for handling

I have a lot of users. Each user has a number of friends. I need a
highscore list pr friend list.

I would like to have it optimized for reading the highscores as opposed to
setting a new highscore as the use case would suggest I would need to read
the list a lot more than I would need write new highscores.

Currently I have the following tables:
CREATE TABLE user (userId uuid, name varchar, highscore int, bestcombo int,
CREATE TABLE highscore (userId uuid, score int, name varchar, PRIMARY
KEY(userId, score, name)) WITH CLUSTERING ORDER BY (score DESC);
... and a tables for friends - for the purpose of this mail assume everyone
is friends with everyone else

Reading the highscore list for a given user is easy. SELECT * FROM
highscores WHERE userId = <id>.

Problem is setting a new highscore.
1. I need to read-before-write to get the old score
2. I'm screwed if something goes wrong and the old score gets overwritten
before all the friends highscore lists gets updated - and it is an highly
visible error due to the same user is on the highscore multiple times.

I would very much appreciate some feedback and/or alternatives to how to
solve this with Cassandra.


View raw message