This is one of those questions that looks like a single question but is really like six questions stapled together.
Start by clarifying requirements: query patterns, data volume, freshness needs, and access control. Then propose a storage and partitioning strategy that balances scalability and query performance, and discuss trade-offs for each component.
Pro tip: Emphasize that freshness requirements drive the architecture: if near-real-time is needed, consider a streaming pipeline to a queryable store; if not, batch processing is simpler and more cost-effective.
Ask about query patterns (by dasher, time range, order status), data volume, freshness expectations, and access control needs. This shapes all subsequent design decisions.
Select a storage system (e.g., columnar store like Redshift/BigQuery for analytics, or NoSQL like Cassandra for high-throughput writes). Partition by time (e.g., daily) and optionally by dasher ID to distribute load.
Create indexes on frequently queried fields (dasher_id, completed_at, order_id). For pagination, use keyset pagination (e.g., WHERE completed_at < last_seen) to avoid deep offset performance issues.
For large exports, use asynchronous jobs that write to object storage (e.g., S3) and notify via email or webhook. Discuss freshness: streaming (low latency, higher cost) vs. batch (higher latency, lower cost).
Implement role-based access control (RBAC) at the API layer, ensuring dashers can only query their own orders, while admins have broader access. Use row-level security in the database if supported.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.