I started with a flat event table and the interviewer pushed back pretty fast.
Start by clarifying requirements and access patterns, then propose a columnar analytical database (e.g., Redshift, BigQuery, ClickHouse) with an event-based schema. Walk through the data flow from ingestion to query, highlighting partitioning, sorting, and pre-aggregation to meet performance needs.
Pro tip: Emphasize that the schema should be optimized for the known queries, not for transactional writes—this shows you understand the difference between OLTP and OLAP. Also, mention that you'd validate the design with a cost model and consider materialized views for the top queries.
Ask about data volume, query frequency, latency requirements, and whether the queries are truly pre-written or ad-hoc. Confirm the need for near real-time vs. batch updates.
Propose a fact table with one row per event, including user_id, event_type, timestamp, and a JSON payload for event-specific properties. Add dimension tables for users, items, and orders.
Select a columnar store and partition by date (e.g., day) and cluster by user_id or item_id. Explain how this speeds up time-range and entity-specific queries.
Describe how events are collected (e.g., via Kafka), processed (e.g., Flink/Spark), and loaded into the analytical store. Mention batch vs. streaming trade-offs.
Propose pre-aggregated tables or materialized views for common queries (e.g., daily user views per item per region). Discuss indexing and query patterns.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.