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.
Explain the trade-offs between OLTP (normalized schema) and OLAP (denormalized/dimensional) schema designs. Provide an example of when you would use a hybrid approach.
You're given the following simplified e-commerce schema:
customers(customer_id PK integer, name varchar, email varchar, created_at timestamp)
orders(order_id PK integer, customer_id integer FK -> customers(customer_id), total_amount decimal, placed_at timestamp)
order_items(order_item_id PK integer, order_id integer FK -> orders(order_id), product_id integer, quantity integer, price decimal)
Spend a minute examining the schema. List the primary keys and foreign keys, describe the relationships between the tables and their cardinality (one-to-many, many-to-one), and name which columns you would inspect first for data-quality issues and why.
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.
Describe the main differences between OLTP and OLAP systems and how schema design changes for each. Using an e-commerce orders domain, explain how you would design the transactional (OLTP) schema and how you'd design the analytical (OLAP) schema. Discuss normalization, indexing, ETL/ELT patterns, query-latency expectations, and typical query types.
For a transactional orders table that stores currency amounts, event timestamps, UUIDs, and JSON metadata, recommend appropriate PostgreSQL data types (for example NUMERIC vs FLOAT, TIMESTAMP vs TIMESTAMP WITH TIME ZONE, UUID, JSONB). Explain the rationale for each choice, precision considerations for money, and how those choices affect indexing and storage efficiency.
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.