Hi Drew,
I think you have 4 requirements. Here are my suggestions.
a) store comments : have a static column family for comments with master data 
like created date, created by , length etcb) when a person votes for a comment, 
increment a vote counter : have a counter column family for incrementing the 
votes for each commentc) display comments sorted by date created: have a column 
family with a dummy row id  'sort_by_time_list',  column names can be date 
created(timeUUID), and column value can be comment id d) display comments 
sorted by number of votes: have a column family with a dummy row id 
'sort_by_votes_list' and column names can be a composite of number of votes , 
and comment id ( as more than 1 comment can have the same votes)

Regards,Roshni

> Date: Wed, 26 Sep 2012 17:36:13 -0700
> From: k...@mustardgrain.com
> To: user@cassandra.apache.org
> CC: d...@venarc.com
> Subject: Re: Data Modeling: Comments with Voting
> 
> Depending on your needs, you could simply duplicate the comments in two 
> separate CFs with the column names including time in one and the vote in 
> the other. If you allow for updates to the comments, that would pose 
> some issues you'd need to solve at the app level.
> 
> On 9/26/12 4:28 PM, Drew Kutcharian wrote:
> > Hi Guys,
> >
> > Wondering what would be the best way to model a flat (no sub comments, i.e. 
> > twitter) comments list with support for voting (where I can sort by create 
> > time or votes) in Cassandra?
> >
> > To demonstrate:
> >
> > Sorted by create time:
> > - comment 1 (5 votes)
> > - comment 2 (1 votes)
> > - comment 3 (no votes)
> > - comment 4 (10 votes)
> >
> > Sorted by votes:
> > - comment 4 (10 votes)
> > - comment 1 (5 votes)
> > - comment 2 (1 votes)
> > - comment 3 (no votes)
> >
> > It's the sorted-by-votes that I'm having a bit of a trouble with. I'm 
> > looking for a roll-your-own approach and prefer not to use secondary 
> > indexes and CQL sorting.
> >
> > Thanks,
> >
> > Drew
> >
> 
                                          

Reply via email to