Re: Data model for boolean attributes

2014-03-21 Thread Ben Hood
Hey Duy Hai, On Fri, Mar 21, 2014 at 7:34 PM, DuyHai Doan wrote: > Your previous "select * from x where flag = true;" translate into: > > SELECT * FROM x WHERE id=... AND flag = true > > Of course, you'll need to provide the id in any case. This is an interesting option, though this app needs

Re: Data model for boolean attributes

2014-03-21 Thread Ben Hood
On Sat, Mar 22, 2014 at 3:32 AM, Ben Hood <0x6e6...@gmail.com> wrote: > Also a very good point. The main query paths the app needs to support are: > > select * from x where flag=true and id = ? and timestamp >= ? and timestamp > <= ? > select * from x where flag=false and id = ? and timestamp >= ?

Re: Data model for boolean attributes

2014-03-21 Thread Ben Hood
On Sat, Mar 22, 2014 at 1:31 AM, Laing, Michael wrote: > Whoops now there are only 2 partition keys! Not good if you have any > reasonable number of rows... Yes, this column family will have a large number of rows. > I monitor partition sizes and shard enough to keep them reasonable in this > so

Re: Data model for boolean attributes

2014-03-21 Thread Laing, Michael
Of course what you really want is this: create table x( id text, timestamp timeuuid, flag boolean, // other fields primary key (flag, id, timestamp) ) Whoops now there are only 2 partition keys! Not good if you have any reasonable number of rows... Faced with a situation like this (alt

Re: Question on CAS

2014-03-21 Thread Tyler Hobbs
On Fri, Mar 21, 2014 at 4:15 PM, DuyHai Doan wrote: > Is there a technical reason not to allow CAS update with inequality or > EXISTS condition ? No, see https://issues.apache.org/jira/browse/CASSANDRA-6839 -- Tyler Hobbs DataStax

Question on CAS

2014-03-21 Thread DuyHai Doan
Hello After reading the latest CQL3 documentation, I realize that it's not possible to perform a CAS update with some conditions: UPDATE users .SET WHERE user_id=... IF password EXISTS UPDATE users .SET WHERE user_id=... IF password != null Is there a technical reason not to allow C

Re: Data model for boolean attributes

2014-03-21 Thread DuyHai Doan
Hello Ben Try the following alternative with composite partition key to encode the dual states of the boolean: create table x( id text, flag boolean, timestamp timeuuid, // other fields primary key (*(id,flag)* timestamp) ) Your previous "select * from x where flag = true;" transla

Data model for boolean attributes

2014-03-21 Thread Ben Hood
Hi, I was wondering what the best way is to lay column families out so that you can to query by a boolean attribute. For example: create table x( id text, timestamp timeuuid, flag boolean, // other fields primary key (id, timestamp) ) So that you can query select * from x where flag