Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

laxmikant.hcl_32751 avatar image
laxmikant.hcl_32751 asked ·

How do I design the data model for an ordering service?

how would we datamodel an order service

where you have to query with status with can have only 5 values (Processing, making, shipped, Delivered, canceled):

select all the orders where status = 'shipped';

Remember we can have millions of orders and status will keep on changing. So how would i avoid wide partition issue here?

Should i say that cassandra is not good fit for this type of query ?

data modeling
1 comment
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Just letting you know that we've had a high volume of questions in the last 48 hours and we've been caught up with the FREE Cassandra Workshop Series so our responses are delayed but we will get to them in the next few hours. Cheers!

0 Likes 0 · ·

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

Your use case sounds like you intend to use Cassandra as the data store for a processing queue. Based on that query, the table would look something like this:

CREATE TABLE orders_by_status (
    status text,
    order_id text
    ...
    PRIMARY KEY (status)
)

But as you said, this isn't a very good way of modelling your data because you will only have a total of 5 partitions which are going to be very large. This won't scale and is not practical at all.

Your query isn't an OLTP workload and I imagine you only need to run it for reporting purposes. Reporting is generally an analytics workload and you should instead consider performing this function using Spark. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.