Data Modeling and Schema Design Questions
Designing relational schemas end to end: entity-relationship modeling, normal forms and deliberate denormalization, primary/foreign keys, data types, and integrity constraints, together with applied schema design driven by real business requirements and query access patterns. Covers modeling a domain from ambiguous requirements, choosing structures that serve the queries a system must run, trading normalization for correctness against denormalization for read performance, and evolving schemas as needs change. Foundational data-modeling judgment for building and reviewing databases, tested through open-ended domain-modeling prompts.
Design a schema and strategy to store and query slowly changing product prices where price can change multiple times per day. Business needs: (1) ability to query price at any historical timestamp, (2) ability to aggregate revenue by price band per day. Discuss storage format, indexes, and typical queries.
Explain primary keys, surrogate keys, and natural keys. When designing schemas for customers and orders in a large OLTP system, when would you choose a surrogate key (auto-increment bigint or UUID) versus a natural key (email, national ID)? Discuss trade-offs: uniqueness guarantees, join performance, index size, replication/merge complexity, human-readability, and give examples where each is appropriate.
Consider this order_items table definition:
order_items(order_id INT, product_id INT, quantity INT, price NUMERIC)
where the combination (order_id, product_id) forms the logical primary key. Explain how composite primary keys work, demonstrate how you'd join this table to orders and products, and describe when you might prefer adding a surrogate key (order_item_id) instead.
Design a schema for tracking promotion redemptions per user and measuring assignment versus usage. Include tables (promotions, promotion_assignments, promotion_redemptions) and the keys and fields needed to calculate metrics like redemption rate and time-to-redemption. Explain how you'd handle one-time-use promotions and the concurrency concerns that come with them.
Propose schema patterns to add auditing and change-tracking to tables for traceability. What columns and structures would you add to capture who changed a row and when, and what approach would you use for row-level history: a separate audit table, database-level change data capture, or an append-only pattern? Discuss the queryability and performance trade-offs of each history-tracking approach.
Unlock Full Question Bank
Get access to all Data Modeling and Schema Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.