Hi,

I read somewhere that the order of columns in the cluster key matters.
Please correct me if I am wrong.

For example,

PRIMARY KEY((prodgroup), status, productid).

Then the below query cannot run,

select * from product where prodgroup='xyz' and prodid > 0

But this query can be run:
select * from product where prodgroup='xyz' and prodid > 0 and status = 0

It means all the preceding part of the clustering key has to be provided in
the query. So with that, if you want to query "Get details of a specific
product"(either active or inactive), you might need to reorder the columns
like PRIMARY KEY((prodgroup), productid, status).

Thanks
Ajay


On Sat, Jan 10, 2015 at 6:03 AM, Tyler Hobbs <ty...@datastax.com> wrote:

> Your proposed model for the table to handle the last query looks good, so
> I would stick with that.
>
> On Mon, Jan 5, 2015 at 5:45 AM, Nagesh <nageswara.r...@gmail.com> wrote:
>
>> Hi All,
>>
>> I have designed a column family
>>
>> prodgroup text, prodid int, status int, , PRIMARY KEY ((prodgroup),
>> prodid, status)
>>
>> The data model is to cater
>>
>>    - Get list of products from the product group
>>    - get list of products for a given range of ids
>>    - Get details of a specific product
>>    - Update status of the product acive/inactive
>>    - Get list of products that are active or inactive (select * from
>>    product where prodgroup='xyz' and prodid > 0 and status = 0)
>>
>> The design works fine, except for the last query . Cassandra not allowing
>> to query on status unless I fix the product id. I think defining a super
>> column family which has the key "PRIMARY KEY((prodgroup), staus,
>> productid)" should work. Would like to get expert advice on other
>> alternatives.
>> --
>> Thanks,
>> Nageswara Rao.V
>>
>> *"The LORD reigns"*
>>
>
>
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>

Reply via email to