400 questions in four levels, all on RetailMart, the practice database of this course. Write every query yourself, get it wrong, read the error, fix it. That is how it sticks.
Answers are coming soon. Post your query in the WhatsApp Community or Discord and we will check it together.
Core syntax, applied directly
KEYS & RELATIONSHIPS
Q1In plain English, what is a primary key and what one rule must its values always satisfy?
Q2What is a foreign key, and what does it enforce between two tables?
Q3A teammate asks how a PRIMARY KEY differs from a UNIQUE constraint. Give the key difference.
Q4What is a composite (multi-column) primary key? Give a realistic example.
Q5Define a natural key and a surrogate key, with one example of each.
Q6Why do most tables use an auto-generated id as the primary key instead of a real-world value?
Q7Can a single table have more than one foreign key? Give an example.
Q8What is a candidate key, and how does it relate to the primary key?
Q9Explain a one-to-many relationship using a customer-and-orders example.
Q10Explain a many-to-many relationship using students and courses.
Q11Explain a one-to-one relationship and give a sensible example.
Q12What does "referential integrity" mean, in one sentence?
Q13Conceptually, what should happen if you try to delete a customer who still has orders?
Q14Give a one-line description of ON DELETE CASCADE versus ON DELETE RESTRICT.
Q15Why can a primary key column never be NULL?
Q16Can a foreign key value be NULL? If so, what would that NULL mean in business terms?
Q17In a foreign-key relationship, what do we mean by the "parent" table versus the "child" table?
Q18How do you physically model a many-to-many relationship in a relational database?
Q19Email is unique per customer, yet customer_id is the primary key. Explain why that choice makes sense.
Q20What is a self-referencing foreign key? Give an example (hint: employees and managers).
Q21What is a lookup (dimension) table? Name one from RetailMart.
Q22Why do surrogate keys stay stable even when a natural value like email or phone changes?
Q23In one sentence, what is the difference between a key and an index?
Q24What is an "orphan" row, and which mechanism prevents it?
Q25Why do we split data across several related tables instead of one very wide table?
NORMALIZATION BASICS
Q26In plain English, what does "normalizing" a database mean?
Q27Name two concrete problems normalization is designed to prevent.
Q28What is data redundancy, and why is storing the same fact in many places risky?
Q29Define an "update anomaly" with a short example.
Q30Define an "insertion anomaly" with a short example.
Q31Define a "deletion anomaly" with a short example.
Q32State what First Normal Form (1NF) requires, in one sentence.
Q33Give an example of a column value that violates 1NF.
Q34What does it mean for a value to be "atomic"?
Q35State what Second Normal Form (2NF) requires, building on 1NF.
Q36In intuitive terms, what is a "partial dependency"?
Q37State what Third Normal Form (3NF) requires, in one sentence.
Q38In intuitive terms, what is a "transitive dependency"?
Q39Explain the mnemonic "the key, the whole key, and nothing but the key."
Q40What is a functional dependency, written A -> B, in plain English?
Q41True or false: a table in 3NF is automatically in 2NF and 1NF. Explain.
Q42Why is it risky to store city, state, pincode AND a derived "region" label all in one row?
Q43Give an everyday example where the same address copied into 5 places caused an inconsistency.
Q44What does "denormalization" mean?
Q45Name one legitimate reason to deliberately denormalize.
Q46Why are reporting and analytics tables often denormalized on purpose?
Q47Is more normalization always better? Answer in one line.
Q48What is a "repeating group," and which normal form forbids it?
Q49Why does normalizing a design usually result in MORE tables?
Q50How does normalization explain why analysts write so many JOINs?
TRANSACTIONS & ACID
Q51What is a database transaction, in plain English?
Q52What does COMMIT do?
Q53What does ROLLBACK do?
Q54Spell out what each letter of ACID stands for.
Q55Explain Atomicity using the classic bank-transfer example.
Q56Explain Consistency in one sentence.
Q57Explain Isolation in one sentence.
Q58Explain Durability in one sentence.
Q59Why is "move money from account A to account B" the textbook example of atomicity?
Q60If the power fails halfway through a transaction, which ACID property protects your data?
Q61Which ACID property ensures two simultaneous users don't corrupt each other's work?
Q62What is an "all-or-nothing" operation?
Q63Give a RetailMart example where two writes should happen in one transaction.
Q64What does BEGIN (or START TRANSACTION) do?
Q65After a successful COMMIT, can you still ROLLBACK that work? One line.
Q66Name one reason a transaction might be rolled back automatically.
Q67What is a "partial update," and why is it dangerous?
Q68What is the difference between auto-commit mode and an explicit transaction?
Q69In plain English, what is a constraint, and how does it support the "C" in ACID?
Q70How does a NOT NULL constraint protect data quality?
Q71How does a CHECK constraint protect data quality? Give an example.
Q72How does a UNIQUE constraint protect data quality?
Q73Why are transactions especially important for an e-commerce checkout?
Q74Once a payment app says "payment successful," what does Durability promise the user?
Q75In one sentence, why do analysts mostly read (SELECT) and rarely manage transactions themselves?
APPLIED TO RETAILMART V3
Q76What is the primary key of customers.customers?
Q77A customer can have several addresses. Which table holds them, and which key connects them?
Q78customers.customers has no city column. Which table holds city, and how do you connect the two?
Q79sales.order_items refers to two parent tables. Name both and the keys involved.
Q80sales.order_items stores prod_id. What does that column point to?
Q81sales.returns has no cust_id. Describe the path you'd follow to find who returned an item.
Q82What kind of relationship exists between sales.orders and sales.order_items?
Q83core.dim_region is a lookup table. What does stores.stores.region_id point to?
Q84Why does RetailMart store region_id in stores instead of the text "North" directly?
Q85customers.tier holds text like "Gold"/"Silver". Is that a normalization smell? Briefly discuss.
Q86Is a customer's full name stored as a column, or derived? If derived, from what?
Q87Which key connects loyalty.members back to a customer?
Q88State the primary key of products.products and how order_items links to it.
Q89Give one one-to-many relationship in RetailMart and name the keys on both sides.
Q90Orders and products are effectively many-to-many. Which table resolves that relationship?
Q91Why does RetailMart separate brand and category into core.dim_brand and core.dim_category?
Q92support.tickets stores customer_id. What relationship does that represent?
Q93In stores.employees, which column links an employee to a department, and what does it reference?
Q94Is order_date stored once on the order, or repeated on each line item? Which is the correct design?
Q95orders carries a net_total (a derived sum of its items). Is that denormalization? When is it safe?
Q96Name two RetailMart tables that look well-normalized (3NF) and say why.
Q97Name one RetailMart field that looks denormalized, and explain the tradeoff behind it.
Q98Sketch how you'd add a many-to-many "which products appear in which promotions" relationship.
Q99Why is the surrogate customer_id a better primary key than using email in customers.customers?
Q100Pick any RetailMart table: state its primary key, one foreign key, and the real-world entity it models.
Combined ideas, multi-step thinking
NORMALIZING SAMPLE TABLES
Q1A junior built Orders(order_id, customer_name, item1, item2, item3). Which normal form does it break, and why?
Q2Rewrite the table in Q1 (sketch) into a design that satisfies 1NF.
Q3Sales(order_id, product_id, product_name, qty) repeats product_name on every line. Which NF is violated and which dependency causes it?
Q4Fix the Sales table in Q3 by decomposing it - name the resulting tables and their keys.
Q5Enrollment(student_id, course_id, student_name, grade) has PK (student_id, course_id). student_name depends only on student_id. Name the violation.
Q6Decompose the Enrollment table in Q5 to reach 2NF.
Q7Employee(emp_id, dept_id, dept_name): dept_name depends on dept_id, which depends on emp_id. Name the dependency type and the NF violated.
Q8Decompose the Employee table in Q7 to reach 3NF.
Q9A customers sheet stores "9876543210, 9123456780" in a single phone cell. Which NF does it break, and how do you fix it?
Q10A table stores order_id plus a JSON blob of all items in one column. Is that 1NF? Discuss the tradeoff for analytics.
Q11Invoice(invoice_id, customer_id, customer_gstin, line_no, item, amount) with PK (invoice_id, line_no): identify the partial dependency.
Q12Why does a table whose primary key is a single column automatically avoid 2NF (partial-dependency) problems?
Q13A reporting table repeats region_name on every row for speed. Which NF does it break, and why might that be acceptable here?
Q14Spot the transitive dependency in Book(book_id, publisher_id, publisher_city).
Q15Product(prod_id, category_id, category_name, gst_rate) where gst_rate depends on category. Name the NF violated and the fix.
Q16A column "address" holds "12 MG Road, Pune, 411001, MH". Is that atomic? How would you normalize it, and what's the tradeoff?
Q17Two rows describe the same customer with "Bengaluru" vs "Bangalore". Which anomaly does this risk, and how does normalization help?
Q18A junior says "one big table means I never JOIN." Give two concrete risks of that approach.
Q19Orders(order_id, coupon_code, coupon_discount_pct) where discount depends on the coupon. Name the dependency and the NF it breaks.
Q20Convert a many-to-many "students <-> courses" design into three tables; name every key.
Q21Shipment(shipment_id, courier_name, courier_phone): spot the transitive dependency and propose the fix.
Q22Why can a table that is only in 1NF still suffer update anomalies? Give an example.
Q23Sketch a table that is in 2NF but NOT 3NF, then show its 3NF version.
Q24A teammate normalized so aggressively that a simple report needs 7 joins. What tradeoff did they hit?
Q25Given a denormalized "wide" sales export, list the ordered steps you'd take to bring it to 3NF.
FUNCTIONAL DEPENDENCIES & DECOMPOSITION
Q26Write the functional dependency that captures "each order belongs to exactly one customer."
Q27List the functional dependencies in Orders(order_id, customer_id, order_date).
Q28What is the difference between a "fully functional dependency" and a partial one?
Q29Given (A,B) -> C and A -> D, which dependency is partial, and why?
Q30What is a "determinant"? Identify it in product_id -> product_name.
Q31If A -> B and B -> C, what can you infer, and what is that inference rule called?
Q32Why does a transitive dependency A -> B -> C violate 3NF?
Q33Decompose R(emp_id, project_id, hours, emp_name), given emp_name depends only on emp_id.
Q34What is a "lossless" decomposition, in one sentence?
Q35Why is it a problem if a decomposition loses information when you re-join the pieces?
Q36Student(roll_no, email, dept, dept_hod) with email unique. List the candidate keys.
Q37If every non-key attribute depends on the whole key and nothing else, which normal form is guaranteed?
Q38State BCNF in one sentence and explain how it is stricter than 3NF.
Q39Give a short example of a table that is in 3NF but not in BCNF.
Q40Why should analysts understand functional dependencies even if they never design schemas?
Q41A table stores both "age" and "date_of_birth". What dependency/quality problem is that, and what's the fix?
Q42Identify the determinant for the junction table order_items(order_id, prod_id, qty).
Q43What does it mean to say the primary key "functionally determines" every other column?
Q44Course(course_id, instructor, instructor_email): which dependency makes this not 3NF?
Q45Describe, step by step, how you'd check on paper whether a table is in 2NF.
Q46Describe, step by step, how you'd check on paper whether a table is in 3NF.
Q47Why does adding a surrogate key sometimes hide a real dependency problem instead of fixing it?
Q48Given (store_id, product_id) -> stock and store_id -> store_region, classify each dependency.
Q49Decompose the table in Q48 to remove the partial dependency.
Q50Restate the BCNF rule "every determinant must be a candidate key" in plain words.
TRANSACTIONS IN PRACTICE
Q51Sketch a transaction (BEGIN ... COMMIT) for "insert one order, then insert its three line items."
Q52In the Q51 example, what should happen if the third item insert fails?
Q53A CHECK constraint requires quantity > 0. A bulk insert includes one row with quantity = 0. What happens to that statement?
Q54Two cashiers sell the last unit of a product at the same instant. Which ACID property is being tested?
Q55Explain a "dirty read" in plain English with a short scenario.
Q56Explain a "non-repeatable read" with a short scenario.
Q57Explain a "phantom read" with a short scenario.
Q58A nightly job updates 1,000,000 rows in one transaction and crashes at row 500,000. What state is the table left in?
Q59Why might you split that 1M-row update into smaller batches instead of one giant transaction?
Q60What is a deadlock, in one sentence, and what typically resolves it?
Q61A FOREIGN KEY blocks inserting an order_item for a non-existent order. Which ACID property does that support?
Q62The CFO asks "can a half-finished refund leave the books unbalanced?" Answer using Atomicity.
Q63Why is it safe to ROLLBACK after an error, but impossible to ROLLBACK after COMMIT?
Q64What does a SAVEPOINT let you do inside a transaction?
Q65Why do long-running transactions hurt concurrency for other users?
Q66When a constraint violation occurs mid-transaction, what is the typical outcome for the statement versus the whole transaction?
Q67Explain how a UNIQUE constraint stops two customers registering the same email even under concurrent inserts.
Q68Why must "place order" be atomic across inventory, order, and payment writes?
Q69A developer disables constraints "for speed" during a load. Which ACID guarantee did they weaken, and what's the risk?
Q70Describe optimistic versus pessimistic concurrency control at a high level.
Q71Why are most SELECT-only workloads safe to run without an explicit transaction?
Q72Name the four standard isolation levels from weakest to strongest.
Q73Which isolation level prevents dirty reads but still allows non-repeatable reads?
Q74Which isolation level prevents all three classic read anomalies?
Q75Why is the strongest isolation level not used by default for every workload?
RETAILMART SCHEMA ANALYSIS
Q76The VP of Sales wants region on every order row. Explain how RetailMart derives region today (stores.region_id -> core.dim_region) and the tradeoff of denormalizing it.
Q77orders.net_total is a stored sum of its order_items. Argue when recomputing from items is safer than trusting the stored total.
Q78A junior wants to add customer_city to customers.customers "to avoid a join." Critique this against 3NF.
Q79customers.tier is stored as text. Propose a normalized alternative and give one pro and one con.
Q80Why is sales.order_items a textbook junction table? Name its likely composite key.
Q81The DBA asks you to state the referential-integrity rule that must hold between order_items and orders.
Q82sales.returns links to an order rather than directly to a customer. Explain the design reasoning.
Q83core.dim_date exists as a separate dimension. What normalization and analytics benefits does a date dimension provide?
Q84What transitive-dependency risk appears if products stored brand_name AND category_name as text instead of brand_id?
Q85Explain why storing first_name and last_name separately (not one full_name) is the more flexible, 1NF-friendly choice.
Q86loyalty.members has no member_id, only customer_id. What does that imply about the members-to-customer relationship?
Q87The CHRO wants a manager hierarchy, but stores.employees has no manager_id. Sketch how you'd model it in a normalized way.
Q88supply_chain.inventory_snapshots uses a composite key with no single snapshot_id. Explain why a composite key fits here.
Q89Why does keeping payment modes in finance.payment_modes (mode_id) instead of free text on orders reduce anomalies?
Q90A report needs brand AND category names for each product. Trace the normalized join path products -> dim_brand -> dim_category.
Q91Argue for and against adding a denormalized monthly_sales summary table for dashboards.
Q92The Compliance Officer asks whether deleting a customer should delete their orders. Discuss CASCADE vs RESTRICT for RetailMart.
Q93Which RetailMart tables are "fact" tables and which are "dimension" tables? Give two of each.
Q94Why is a surrogate prod_id a better key than using the product name in products.products?
Q95Identify one place in RetailMart where a genuine 1:1 relationship could exist, and how you'd model it.
Q96Explain how foreign keys across sales, customers, and products keep RetailMart consistent.
Q97A stakeholder wants reviews linked to both a product and a customer. Which columns on customers.reviews support that?
Q98Why might the analytics layer (views / materialized views) deliberately denormalize RetailMart for query speed?
Q99Give an example of an update anomaly that the customers/addresses split prevents.
Q100Audit any three RetailMart tables and label each as 3NF or intentionally denormalized, with a one-line reason.
Interview grade, edge cases
NORMALIZATION EDGE CASES & BCNF
Q1Give a table that is in 3NF but not BCNF, and name the exact dependency that breaks BCNF.
Q2Explain why decomposing to BCNF can force you to lose a functional dependency (the dependency-preservation tradeoff).
Q3When is it defensible to stop at 3NF rather than push to BCNF? Justify with a tradeoff.
Q4What is a multivalued dependency, and which normal form (4NF) addresses it?
Q5Give an example where 4NF matters - a table mixing two independent multivalued facts.
Q6Define "denormalization for read performance" and state the integrity cost you accept in return.
Q7A star-schema fact table is deliberately not in 3NF. Explain why dimensional modeling tolerates that.
Q8Contrast the design goals of OLTP (normalized) versus OLAP (dimensional/denormalized) systems.
Q9Why can over-normalization specifically hurt analytical query performance?
Q10A surrogate key is added to a table that already had a solid natural key. Name a real downside.
Q11Explain how a slowly changing dimension complicates the idea of a single normalized "truth."
Q12Storing a computed column (line_total = qty * price) technically breaks 3NF. When is it worth doing anyway?
Q13Describe a case where two columns are mutually dependent (A -> B and B -> A) and what that implies for candidate keys.
Q14Explain why NULLs complicate reasoning about functional dependencies.
Q15A table looks 3NF "by inspection," but a real business rule creates a dependency the schema fails to capture. How can that happen?
Q16Tie the expectation "an analyst should read an ER diagram" back to functional dependencies and keys.
Q17Distinguish logical normalization from physical storage layout, and why both matter.
Q18When does flattening a dimension's attributes INTO a fact table make sense?
Q19A team keeps a normalized core plus a denormalized reporting layer. Name two risks of keeping them in sync.
Q20Why is "the same data in two places" acceptable in a materialized view but not in an OLTP base table?
Q21Give a case where a junction table needs its OWN attributes (e.g., enrollment date), and why that's correct.
Q22Explain how one badly chosen composite key can create both a 2NF and a BCNF problem at once.
Q23Explain the classic tradeoff: normalization saves storage but can raise JOIN/CPU cost.
Q24A stakeholder demands one flat "order + customer + product" table. Defend delivering it as a VIEW, not a base table.
Q25Summarize, in three bullets, a decision framework for "normalize vs denormalize" on an analytics team.
ISOLATION, CONCURRENCY & ANOMALIES
Q26Map each read anomaly (dirty, non-repeatable, phantom) to the lowest isolation level that prevents it.
Q27Explain READ COMMITTED and exactly which anomaly it still permits.
Q28Explain REPEATABLE READ and which anomaly the SQL standard says it can still permit.
Q29Explain SERIALIZABLE and the guarantee it provides.
Q30PostgreSQL defaults to READ COMMITTED. What does that mean for two analysts running long reports concurrently?
Q31What is a "write skew" anomaly, and which isolation level prevents it?
Q32Explain MVCC at a high level and why, in Postgres, readers don't block writers.
Q33Why can a long analytical SELECT in Postgres see a consistent snapshot even while writes are happening?
Q34Define a "lost update," and describe how isolation or explicit locking prevents it.
Q35Two transactions each read a balance then write balance - 100. Walk through the lost-update scenario and a fix.
Q36What is SELECT ... FOR UPDATE used for, and when would an analyst-adjacent job need it?
Q37Give a concrete two-transaction deadlock example and explain how the database resolves it.
Q38Why does stronger isolation generally reduce concurrency and throughput?
Q39Distinguish a shared lock from an exclusive lock.
Q40Why might an analyst's huge, long-running report transaction interfere with maintenance or cause table bloat in Postgres?
Q42What is the practical risk of running every transaction at SERIALIZABLE in a high-throughput OLTP system?
Q43How does a UNIQUE constraint behave when two concurrent transactions insert the same value?
Q44Why is "retry on serialization failure" a normal application pattern under SERIALIZABLE?
Q45Give a scenario where allowing dirty reads would feed a finance dashboard a wrong number.
Q46Why are read-only replicas a common way to shield analysts from OLTP contention?
Q47Explain, without deep internals, how durability is implemented via a write-ahead log.
Q48What does flushing/fsync to disk have to do with the D in ACID?
Q49Why can a COMMIT be acknowledged to the client only after the log is durably written?
Q50Summarize the tradeoff triangle: isolation strength vs concurrency vs developer complexity.
SCHEMA DESIGN PROBLEMS
Q51Sketch normalized DDL for "customers place orders containing many products." Name keys and foreign keys.
Q52Design "products belong to many promotions, with a promotion-specific discount." Where does the discount column live?
Q53Design "employees report to managers" (self-referencing). Show the foreign key.
Q54Design "a store stocks many products, each with a per-store quantity." What is the primary key of the stock table?
Q55Model "a customer has exactly one loyalty membership." Is it 1:1 or 1:M? Justify and sketch.
Q56Model "an order uses at most one coupon; a coupon is used by many orders." Which side holds the FK?
Q57Design a date dimension and explain three analytics-useful columns it should carry.
Q58You must keep product price history (never overwrite). Sketch a normalized design.
Q59Tickets can change status many times. Sketch the status-history table and its keys.
Q60Requirement: tag products with arbitrary tags. Design the normalized many-to-many tag schema.
Q61"An address can belong to a customer OR a store." Discuss polymorphic-FK options and a cleaner normalized alternative.
Q62Design a schema that makes it impossible to store both age and date_of_birth redundantly.
Q63Per-line tax depends on product category. Where should the category -> tax_rate mapping live to stay 3NF?
Q64Design "a campaign runs on many platforms; each platform run has its own spend." Sketch the tables.
Q65A junior proposes phone1, phone2, phone3 columns on customers. Redesign it normalized and say which NF it fixes.
Q66Model "a return is for one order and may cover several of that order's items." Sketch the keys.
Q67Design a supplier-product catalog where one product is sourced from multiple suppliers at different costs.
Q68Surrogate vs natural key for a table of Indian PIN codes - choose and justify.
Q69Sketch how FK design enforces "an order's items all belong to that same order."
Q70Reporting need: one row per (customer, month) with totals. Base table or derived/materialized object? Defend the choice.
Q71Design "products in categories, categories in parent categories" (a hierarchy). Show the self-reference.
Q72Support soft-deletes without breaking foreign keys. Sketch an approach and name one downside.
Q73"A warehouse records inventory snapshots per product per day." What is the natural composite key?
Q74"A customer has many payment methods, exactly one default." How do you enforce the single default cleanly?
Q75Critique a design that dumps everything into one "attributes" JSON column instead of typed columns, for analytics.
RETAILMART DEEP DIVE & INTEGRITY
Q76Trace the full foreign-key chain from one sales.order_items row up to the customer and down to the product.
Q77orders.net_total could drift from SUM(order_items). Propose a periodic reconciliation an analyst could run.
Q78Argue whether customers.tier should be a FK to a tiers dimension, given its heavy use in RFM/segmentation.
Q79The Head of Logistics wants courier on every shipment row. Explain how RetailMart models courier and whether to denormalize.
Q80Explain why sales.returns using refund_amount (not return_amount) and having no cust_id is a deliberate, defensible design.
Q81If region were stored as text on stores instead of region_id, give a concrete update anomaly that could occur.
Q82Map RetailMart to a star schema: pick one fact table and four dimensions it would join to.
Q83Why is core.dim_category being flat (no parent_category_id) a reasonable simplification, and when would a hierarchy be needed?
Q84The Compliance Officer wants an audit trail of price changes. Which RetailMart structure supports change detection, and how?
Q85Describe, conceptually, how you'd verify that every order_items.prod_id exists in products.products (an integrity audit).
Q86Identify a RetailMart table where a denormalized column is justified for performance, and name the safeguard you'd add.
Q87Marketing stores platform names as free text. Propose a normalized fix and state the reporting benefit.
Q88Why does separating finance.payment_modes from orders make adding a new method (e.g., "UPI Lite") safe?
Q89loyalty.members carries tier_id while customers.customers also has tier. Is that redundancy a real problem? Discuss.
Q90State the integrity rule that should prevent a review existing for a non-existent product in customers.reviews.
Q91A stakeholder wants one big denormalized sales view for Excel users. Outline its columns and the joins that build it.
Q92Explain how splitting orders from order_items prevents an insertion anomaly when an order has many products.
Q93Why is web_events.page_views using its own view_id and view_timestamp (not reusing order keys) correct design?
Q94Discuss the integrity tradeoff of supply_chain.inventory_snapshots using a composite key and no surrogate id.
Q95The CFO wants guaranteed-correct revenue. Explain why computing from order_items with status filters can beat a stored total.
Q96Identify two 1:M relationships in RetailMart and one effectively M:N relationship with its resolving table.
Q97Propose referential integrity for "an employee belongs to exactly one store and one department."
Q98Explain why dimension tables changing rarely (dim_region, dim_brand) is what makes denormalizing them into reports relatively safe.
Q99A new analyst flattens customers + addresses + orders into one base table "to make life easy." List three concrete risks.
Q100Across the whole schema, summarize in four bullets how RetailMart balances normalization (integrity) with analyst convenience.
Production scenarios, optimisation
NORMALIZATION & MODELING AT SCALE
Q1Designing RetailMart's analytics layer: argue for a Kimball star schema versus a fully normalized 3NF warehouse, with tradeoffs.
Q2Explain how a wide denormalized fact plus columnar storage can beat a normalized model for analytics - and when it doesn't.
Q3Design a Type-2 slowly-changing dimension for customer tier history: sketch keys, effective dates, and a current flag.
Q4When do Type 1, Type 2, and Type 3 SCDs each make sense for a customer dimension? Give a rule of thumb.
Q5A team proposes an EAV (entity-attribute-value) table to allow "any attribute." Critique it for analytics and offer an alternative.
Q6How do normalization decisions change when storage is cheap but JOINs over billions of rows are expensive?
Q7You must serve OLTP correctness and OLAP speed on the same data. Describe a normalized-base -> denormalized-marts architecture and its sync risk.
Q8Give concrete criteria for choosing a JSONB column over typed normalized columns.
Q9Explain "one fact per grain" and why mixing grains in a single fact table is a modeling error.
Q10Design a bridge table for orders-to-promotions where multiple promos can stack; how do you avoid double-counting revenue?
Q11How would you model returns so that net revenue is always reconstructable without double-subtracting?
Q12Explain the point-in-time-correctness risk of denormalizing customer tier onto every order row when tier changes over time.
Q13Why is classifying measures as additive / semi-additive / non-additive a modeling concern adjacent to normalization?
Q14Design a conformed-dimension strategy so sales and supply_chain share one product dimension.
Q15A denormalized reporting table drifts from source after a backfill. Design reconciliation plus alerting.
Q16Explain when surrogate keys are mandatory in a warehouse even though source systems already have natural keys.
Q17Defend or reject the maxim "normalize until it hurts, then denormalize until it works."
Q18How do late-arriving facts (an order_item inserted days later) break naive denormalized aggregates, and how do you guard against it?
Q19Explain idempotency in an ETL upsert and why it matters for consistency at the pipeline level.
Q20Design a schema that supports both "current price" and "price as of order date" without contradiction.
Q21Why can blindly adding indexes to "fix" a denormalized table create write-amplification problems?
Q22Distinguish normalization (logical) from partitioning/sharding (physical scaling) and explain why they're orthogonal.
Q23A product belongs to multiple categories. Show the M:N design and explain the revenue-by-category allocation problem it creates.
Q24How would you model multi-currency orders correctly, avoiding storing only a converted total?
Q25List a staff-level five-point checklist you always apply when reviewing a teammate's schema change.
CONCURRENCY, MVCC & DURABILITY (DEEP)
Q26Explain PostgreSQL MVCC: how row versions (xmin/xmax) let readers and writers avoid blocking each other.
Q27Why does MVCC create dead tuples, and what is VACUUM's job? Tie it to long analyst transactions.
Q28A long-running reporting transaction holds back the xmin horizon. Explain the bloat and vacuum consequences.
Q29Explain snapshot isolation and how it differs from true serializability.
Q30What is Serializable Snapshot Isolation (SSI) in Postgres, and what kind of conflict does it detect?
Q31Give a write-skew example (e.g., two on-call doctors) and explain why only SERIALIZABLE prevents it.
Q32Explain how READ COMMITTED can produce a non-repeatable read between two SELECTs in one transaction.
Q33Walk through how SELECT ... FOR UPDATE plus a re-check eliminates a lost update.
Q34Distinguish row-level from table-level locks and when each is acquired.
Q35Describe a deadlock cycle across three transactions and how the detector breaks it.
Q36Why is application-level retry the correct response to a serialization_failure (SQLSTATE 40001)?
Q37Explain how the write-ahead log guarantees durability and enables crash recovery (redo).
Q38What are checkpoints, and what is the tradeoff between checkpoint frequency and recovery time?
Q39Explain synchronous versus asynchronous replication and the durability/latency tradeoff.
Q40With async replicas, what consistency anomaly can an analyst hit reading a replica right after a write?
Q41Explain "read your own writes" consistency and why it can break on a lagging replica.
Q42Why does a UNIQUE index (not merely a check) enforce uniqueness correctly under concurrency?
Q43How do advisory locks differ from row locks, and give one legitimate use case.
Q44State the double-booking problem and three distinct ways to prevent it (unique constraint, locking, serializable).
Q45Explain why COUNT(*) can differ between two reads under READ COMMITTED but not under REPEATABLE READ.
Q46How can an analyst's accidental "BEGIN" with no COMMIT (idle-in-transaction) harm a production database?
Q47Explain why chunked writes improve throughput but sacrifice all-or-nothing semantics across chunks.
Q48Describe how you'd make a multi-step ETL atomic across staging and final tables.
Q49Why is "exactly once" hard in distributed pipelines, and how does idempotent upsert approximate it?
Q50Summarize how isolation, durability, and replication interact when you promise "the dashboard is never wrong."
CONSISTENCY, DISTRIBUTED & TRADEOFFS
Q51State the CAP theorem and what it forces you to sacrifice during a network partition.
Q52Contrast strong versus eventual consistency with a concrete e-commerce example.
Q53Why do many analytics systems accept eventual consistency while checkout cannot?
Q54Contrast BASE with ACID and say where each is the right fit.
Q55A microservice split puts orders and inventory in separate databases. How is cross-service atomicity lost, and what pattern recovers it?
Q56Explain the saga pattern and compensating transactions using an order/payment/inventory flow.
Q57Why can't a distributed system trivially provide single-node ACID across services?
Q58Explain two-phase commit and why it is often avoided in practice.
Q59What is the transactional outbox pattern, and which consistency problem does it solve?
Q60An event pipeline double-processes a message. Which property saves the aggregates, and how?
Q61Explain why "the dashboard number depends on which replica you hit," and how to make it deterministic.
Q62Discuss the tradeoff of pre-aggregating via materialized views versus always computing from raw for correctness.
Q63When is "good enough, 5-minutes-stale" the right consistency target for an executive dashboard?
Q64How do late or out-of-order events break windowed aggregates, and what mitigations exist (watermarks/grace)?
Q65Why does duplicating data across services trade integrity for availability and latency?
Q66Explain the limit of referential integrity: a FK works inside one database but not across two services. Implication?
Q67How would you guarantee a financial report ties out exactly given an eventually-consistent source?
Q68Explain idempotency keys for a "retry payment" button and the anomaly they prevent.
Q69Why does read-after-write matter when an analyst inserts a fix then immediately re-queries a replica?
Q70A normalized OLTP source feeds a denormalized warehouse via CDC. What consistency guarantee does CDC actually give?
Q71Why is wall-clock time unreliable for ordering events across distributed nodes, and what is used instead?
Q72Explain the reconciliation pattern: periodic full re-compute to correct drift in incremental aggregates.
Q73When does a single source of truth become impossible, and how do you choose the authoritative source?
Q74Why should analysts know whether they're querying the OLTP primary, a replica, or the warehouse?
Q75Summarize the spectrum from ACID-strong to eventually-consistent and where RetailMart's analytics layer should sit.
RETAILMART END-TO-END AUDIT & DESIGN CRITIQUE
Q76Run a normalization audit of customers + addresses + orders + order_items: rate each table's normal form and justify.
Q77Define RetailMart's canonical revenue (which table, which status filters, how returns are handled) and explain why it's authoritative.
Q78Propose a Type-2 history design so RetailMart can answer "what tier was this customer ON the order date?"
Q79Design a guardrail to keep orders.net_total consistent with order_items (constraint vs trigger vs scheduled check) and pick one per OLTP/analytics context.
Q80Map RetailMart into a full sales star schema: state the fact grain, the measures, and every dimension.
Q81Critique keeping customers.tier as text versus a tier dimension, weighing reporting, integrity, and SCD needs.
Q82Design how RetailMart can expose a denormalized one-row-per-order-line mart without corrupting the normalized base.
Q83The analytics layer builds 76 views + 13 materialized views. Explain the refresh/consistency risks and how you'd schedule and monitor them.
Q84A monthly-sales materialized view drifts after a backfill of late orders. Design detection plus correction.
Q85Audit RetailMart's denormalized fields (net_total, any cached labels) and classify each as safe or risky, with reasoning.
Q86Model multi-warehouse inventory so "stock as of a date" is reconstructable; tie it to inventory_snapshots' composite key.
Q87The Compliance Officer needs an immutable audit log of refunds. Design it (append-only, keys) and state the durability requirement.
Q88Explain how you'd guarantee a dashboard's "total customers" matches the OLTP source despite replication lag.
Q89Two reports disagree on revenue by Rs 2 Cr. Walk through a systematic root-cause using normalization and consistency concepts.
Q90Design a reconciliation job that flags rows where SUM(order_items) != orders.net_total, and define what to alert on.
Q91Critique using customer email as a cross-system join key instead of a stable surrogate customer_id.
Q92order_date is a DATE (no time). Explain the consistency implication for "orders per hour" and name the correct alternative source.
Q93Propose a conformed product dimension so sales, supply_chain, and manufacture all agree on what a product is.
Q94Design point-in-time-correct revenue-by-region assuming a store could change region over time.
Q95Marketing wants attribution joining web_events to orders. Discuss the key and consistency challenges (session_id, customer_id, timing).
Q96Explain why "delete a customer" is dangerous in RetailMart, and design a compliant anonymization that preserves referential integrity.
Q97Build the case for a separate read replica or warehouse for analysts, citing the MVCC/bloat and isolation issues from earlier sections.
Q98A stakeholder wants real-time AND always-correct AND cheap dashboards. Use CAP/consistency tradeoffs to explain why they must choose.
Q99Propose a five-point weekly data-integrity test suite for RetailMart (FK orphans, total drift, duplicate keys, NULL keys, status sanity).
Q100Write a one-paragraph design philosophy for RetailMart that balances integrity, performance, and analyst usability at a staff-engineer level.