You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Nagesh <na...@gmail.com> on 2015/01/05 12:45:51 UTC
Cassandra primary key design to cater range query
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"*
Re: Cassandra primary key design to cater range query
Posted by Tyler Hobbs <ty...@datastax.com>.
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 <na...@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/>