Go day / phone instead of phone / day this way you won't have a rk growing forever .
A comprise would be month / phone as the row key and then use the date time as the first part of a composite column. On Thursday, February 7, 2013, Kanwar Sangha <kan...@mavenir.com> wrote: > Thanks Aaron ! > > > > My use case is modeled like “skype” which stores IM + SMS + MMS in one conversation. > > > > I need to have the following functionality – > > > > · When I go offline and come online again, I need to retrieve all pending messages from all my conversations. > > · I should be able to select a contact and view the ‘history’ of the messages (last 7 days, last 14 days, last 21 days…) > > · If I log in to a different device, I should be able to synch at least a “few days” of messages. > > · One conversation can have multiple participants. > > · Support full synch or delta synch based on number of messages/history. > > > > I guess this makes the data model span across many CFs ? > > > > > > > > > > From: aaron morton [mailto:aa...@thelastpickle.com] > Sent: 06 February 2013 22:20 > To: user@cassandra.apache.org > Subject: Re: DataModel Question > > > > 2) DynamicComposites : I read somewhere that they are not recommended ? > > You probably wont need them. > > > > Your current model will not sort message by the time they arrive in a day. The sort order will be based on Message type and the message ID. > > > > I'm assuming you want to order messages, so put the time uuid at the start of the composite columns. If you often want to get the most recent messages use a reverse comparator. > > > > You could probably also have wider rows if you want to, not sure how many messages kids send a day but you may get by with weekly partitions. > > > > The CLI model could be: > > row_key: <phone_number : day> > > column: <time_uuid : message_id : message_type> > > > > You could also pack extra data used JSON, ProtoBuffers etc and store more that just the message in the column value. > > > > If you use using CQL 3 consider this: > > > > create table messages ( > > phone_number text, > > day timestamp, > > message_sequence timeuuid, # your timestamp > > message_id integer, > > message_type text, > > message_body text > > ) with PRIMARY KEY ( (phone_number, day), message_sequence, message_id) > > > > (phone_number, day) is the partition key, same the thrift row key. > > > > message_sequence, message_id is the grouping columns, all instances will be grouped / ordered by these columns. > > > > Hope that helps. > > > > > > > > ----------------- > > Aaron Morton > > Freelance Cassandra Developer > > New Zealand > > > > @aaronmorton > > http://www.thelastpickle.com