Please advise if this is not the right place to ask this.
I'm trying to find a suitable partition key/sort key pair for a simple relational model (a seller has many customers, a customer has many orders) that covers the following query patterns:
- For a given seller, get all orders for a given customer in a date range;
- For a given seller, get all orders for all customers in a date range.
My order ids are in the form yyyy-mm-dd-random_string, so it is sortable by date. There is only one item per order.
Using seller_id as partition key, and customer_id#order_id as sort key covers the first use case, but there is no way to "jump" over the customers.
How can I get these two queries from the same records?
Bonus:
- Is there a way to do it without secondary indexes?
- Is there a general approach for "jumping" over hierarchical relations?
begins_with("customer_id#2019")and it gets me all the orders for a customer for year 2019. But how can I get all orders placed in 2019 for all customers? Something like/.*#2019.*/.