Views and Materialized Views: practice questions
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.
Easy 100 questions Medium 100 questions Hard 100 questions Crazy 100 questions
Core syntax, applied directly
CONCEPTUAL Q1 What is a VIEW (a stored SELECT, run live on each query)? Q2 What is a MATERIALIZED VIEW (a stored result set, refreshed on demand)? Q3 Why share tested logic as a view rather than copy-pasting SQL? Q4 View vs MV: which trades freshness for query speed, and why? Q5 What does CREATE OR REPLACE VIEW do (when allowed)? Q6 Why are views great for the "metrics layer" of a stack? Q7 What does CREATE MATERIALIZED VIEW ... WITH NO DATA do? Q8 What does REFRESH MATERIALIZED VIEW do? Q9 What does REFRESH MATERIALIZED VIEW CONCURRENTLY require (unique index)? Q10 Why does a concurrent refresh need a unique index on the MV? Q11 Layered stack: raw -> cleaned -> metrics - what lives where? Q12 What is a "raw" view (passthrough + minimal column selection)? Q13 What is a "cleaned" view (typed, trimmed, deduped values)? Q14 What is a "metrics" view (aggregates, KPIs)? Q15 Why are views read-only abstractions for downstream consumers? Q16 What does DROP VIEW ... CASCADE do (and why is it risky)? Q17 How do you list dependencies on a view before dropping (concept)? Q18 Why does a view inherit security from underlying tables? Q19 What is the difference between CREATE VIEW and CREATE TEMP VIEW? Q20 Why an MV makes sense for slow analytics that don't need real-time freshness? Q21 What's the freshness model of a normal view (always current) vs MV (refreshed)? Q22 Why is a daily refresh schedule common for MVs (and when is hourly needed)? Q23 Can you index a materialized view? (Yes - Topic 20 indexing applies). Q24 Why is a view a good place to enforce join discipline (one canonical join)? Q25 Name two analyst reports you'd ship as a view vs as an MV. PLAIN VIEWS Q26 Create v_delivered_orders: orders WHERE order_status = 'Delivered'. Q27 Create v_customer_full_name: customer_id + (first_name||' '||last_name). Q28 Create v_orders_enriched: orders joined to customers and stores (key columns). Q29 Create v_orders_clean: filter Failed/Cancelled out + standardize status case. Q30 SELECT through v_delivered_orders and count rows. Q31 Create v_high_value_orders: net_total > 5000. Q32 Create v_gold_platinum_customers: tier IN ('Gold','Platinum'). Q33 Create v_products_with_brand: products + brand + category names. Q34 Create v_returns_with_customer: returns -> orders -> customers. Q35 Create v_revenue_by_region: aggregated SUM(net_total) per region. Q36 Create v_orders_2025: just orders from 2025 (date_trunc, Topic 23). Q37 Drop v_high_value_orders. Q38 Create or replace v_orders_clean to also exclude Returned. Q39 Create v_employee_with_dept: employees + department name. Q40 Create v_top_customers: top 100 customers by lifetime spend. Q41 Create v_orders_with_items_count: orders + count(items). Q42 Create v_active_stores: stores with at least one order. Q43 Create v_customer_latest_order using DISTINCT ON (Topic 22). Q44 Create v_monthly_revenue using date_trunc('month') (Topic 23). Q45 SELECT a slice from v_monthly_revenue for one year. Q46 Create v_tickets_open: tickets not yet resolved. Q47 Create v_pay_slip_clean: parse month-year text into a real date (Topic 23). Q48 Create v_reviews_clean: trim text + drop NULL ratings. Q49 List the row count of every view you've created so far. Q50 Drop a view safely after checking no other view depends on it. MATERIALIZED VIEWS Q51 Create MV mv_monthly_revenue: month, total revenue, order count. Q52 REFRESH MATERIALIZED VIEW mv_monthly_revenue. Q53 Create UNIQUE INDEX on mv_monthly_revenue(month) (prereq for CONCURRENTLY). Q54 REFRESH MATERIALIZED VIEW CONCURRENTLY mv_monthly_revenue. Q55 Create mv_revenue_by_region with a unique key + index. Q56 Create mv_customer_lifetime: per customer total orders, total revenue, latest order. Q57 Add a UNIQUE INDEX on mv_customer_lifetime(customer_id). Q58 Create mv_store_kpis: per store monthly revenue & order count. Q59 Create mv_product_sales: per product units sold + revenue. Q60 Create mv_orders_with_items_count (heavy join - good MV candidate). Q61 Create mv_top_customers_by_year: top 100 per year. Q62 Create mv_returns_by_category. Q63 Create mv_calls_hourly: per hour-of-day call count & median duration (Topic 22/23). Q64 Create mv_page_views_hourly per device. Q65 Create mv_employee_salary_latest: latest salary per employee (DISTINCT ON, Topic 22). Q66 Create mv_inventory_latest: latest snapshot per (warehouse, prod). Q67 Add an index on mv_inventory_latest(warehouse_id, prod_id) (Topic 20). Q68 REFRESH the MV and re-count rows. Q69 Create MV ... WITH NO DATA; then REFRESH to populate. Q70 Drop an MV you created. Q71 Create mv_revenue_quarterly with a unique (region, quarter) key. Q72 Create mv_ticket_sla: per priority median + P95 resolution hours (Topic 22). Q73 Create mv_daily_revenue (gap-filled spine, Topic 23) + UNIQUE INDEX(d). Q74 Compare row counts: live aggregate query vs MV (should match post-REFRESH). Q75 EXPLAIN ANALYZE the MV scan (Topic 19) - note index-only scan if applicable. LAYERED STACK & MAINTENANCE Q76 Layer 1 (raw): v_orders_raw = passthrough of sales.orders with renamed cols. Q77 Layer 2 (cleaned): v_orders_clean built on v_orders_raw (filter + trim). Q78 Layer 3 (metrics): v_monthly_revenue_kpis built on v_orders_clean. Q79 Show that v_monthly_revenue_kpis transitively depends on v_orders_raw. Q80 Materialize the metrics layer: mv_monthly_revenue_kpis. Q81 Replace the metrics view with an MV; consumers keep the same name (drop + create). Q82 Stack: raw -> cleaned -> metrics for returns; one MV at the top. Q83 Stack: raw -> cleaned -> metrics for tickets (SLA dashboard). Q84 Decision: which of your 3 layers should be an MV (heaviest aggregate)? Q85 REFRESH order: refresh bottom-up vs top-down - discuss. Q86 Detect dependent views before dropping a base view (pg_depend/pg_views). Q87 DROP a view CASCADE and explain what got dropped (then recreate). Q88 Schedule strategy: daily vs hourly refresh - pick for monthly_revenue_kpis. Q89 Add a UNIQUE INDEX on each MV that needs CONCURRENTLY. Q90 Refresh strategy: stale-MV note vs CONCURRENT - tradeoffs. Q91 Build a "customer-360" view (Topic 24 spirit, relational) on top of the stack. Q92 Time-series MV (Topic 23): daily revenue + 7-day MA, with index. Q93 Percentile MV (Topic 22): median & P95 net_total per region. Q94 Pivot MV (Topic 21): region x month revenue. Q95 Build an MV for the executive KPI strip (orders, median, P95, latest). Q96 Document each MV's refresh cadence in a comment header. Q97 Test view substitutability: same query on view vs base - equal rows? Q98 Drop all the MVs you created (cleanup) - list first, then drop. Q99 Drop all the views you created (in dependency-safe order). Q100 Recreate the full 3-layer stack as a script you can re-run. Combined ideas, multi-step thinking
CONCEPTUAL Q1 Layered stack discipline: what belongs in raw / cleaned / metrics and why. Q2 When does a view enable an index-only scan on the base table? Q3 View inlining: how the planner expands views during optimization. Q4 Why CREATE OR REPLACE VIEW requires the same column list shape. Q5 Updatable vs non-updatable views in Postgres (concept). Q6 WITH CHECK OPTION semantics (CASCADED vs LOCAL) - concept. Q7 View vs MV vs summary table - three-way decision matrix. Q8 Why MV CONCURRENTLY requires a UNIQUE INDEX (no full lock). Q9 Indexing strategy for MVs (Topic 20): primary lookup index + secondary. Q10 Refresh ordering for a stack of MVs (dependencies). Q11 Detect view dependencies via pg_depend / pg_views (concept). Q12 DROP CASCADE trap: how to inventory dependents first. Q13 Schema namespacing for views (e.g. analytics.v_*) - why it matters. Q14 View security & search_path pitfalls (concept). Q15 When inlining hurts the plan (many small views combined). Q16 Materializing a percentile MV (Topic 22) - refresh cost vs query cost. Q17 Time-series MVs (Topic 23): daily vs hourly grain trade-offs. Q18 Pivot MV (Topic 21) shape vs long MV - when which is right. Q19 EXPLAIN ANALYZE on MV vs underlying view (Topic 19) - what to look for. Q20 Stale-data tolerance per consumer - driving refresh cadence. Q21 Combining views from many schemas - naming + ownership. Q22 Documenting an MV's refresh contract in a comment. Q23 When a view becomes a performance crutch (anti-pattern). Q24 Versioning views (v2 alongside v1) for safe migration. Q25 Anti-patterns: views over views over views (depth that hurts). LAYERED STACKS Q26 Build the orders stack: v_orders_raw -> v_orders_clean -> v_orders_enriched. Q27 v_orders_clean: trim status, drop Failed, normalize date typing. Q28 v_orders_enriched: join customers, stores, region, payment_mode. Q29 v_revenue_by_region_month built on the enriched view. Q30 Returns stack: v_returns_raw -> v_returns_clean -> v_returns_by_category. Q31 Tickets stack with SLA: v_tickets_clean -> v_ticket_sla (median/P95). Q32 Customers stack: v_customers_clean (full_name, primary city via addresses). Q33 Employees stack: v_employees_clean + v_employee_with_dept. Q34 Products stack: v_products_clean + v_products_with_brand_category. Q35 Build v_inventory_latest on top of supply_chain.inventory_snapshots (Topic 22). Q36 Build v_customer_latest_order (DISTINCT ON) and v_customer_first_order. Q37 Build v_orders_with_basket (items joined + count). Q38 Build v_orders_with_payment (latest payment, Topic 22). Q39 Build v_revenue_by_region quarter (Topic 23) on top of the enriched orders. Q40 Stack a percentiles layer: v_region_aov_percentiles (Topic 22). Q41 Stack a window-rank layer: v_top_customers_per_region (Topic 16). Q42 Stack a time-series gap-filled layer (Topic 23) v_daily_revenue. Q43 Stack a pivot layer (Topic 21): v_region_x_month_revenue. Q44 Build v_customer_360 as a layered view (Topic 24 spirit, relational). Q45 Cross-stack: v_orders_clean + v_customers_clean -> v_orders_with_customer. Q46 Show that v_revenue_by_region depends transitively on v_orders_raw. Q47 Rebuild a view with CREATE OR REPLACE; assert column list unchanged. Q48 Add a new column to the cleaned layer; propagate through the stack. Q49 Drop a leaf view safely (verify no dependents first). Q50 Write a "recreate-stack" script that runs idempotently. MV MAINTENANCE & INDEXING Q51 Convert v_monthly_revenue -> MV; add UNIQUE INDEX(month); REFRESH CONCURRENTLY. Q52 mv_revenue_by_region (region, month) + UNIQUE INDEX; concurrent refresh. Q53 mv_customer_lifetime (customer_id PK) + indexes for tier / region. Q54 mv_store_kpis monthly per store + UNIQUE INDEX(store_id, month). Q55 mv_product_sales by product + secondary index on category. Q56 mv_top_customers_per_region (Topic 16) + index on (region, rank). Q57 mv_ticket_sla per priority median+P95 (Topic 22) + UNIQUE INDEX(priority). Q58 mv_calls_hourly (hour-of-day, Topic 23) + UNIQUE INDEX(hour). Q59 mv_inventory_latest (warehouse_id, prod_id) + UNIQUE INDEX. Q60 mv_daily_revenue (date, Topic 23) gap-filled + UNIQUE INDEX(d). Q61 mv_revenue_quarterly (region, quarter) + UNIQUE INDEX. Q62 mv_returns_by_category (category) + UNIQUE INDEX. Q63 mv_pay_slip_monthly (employee_id, period) + UNIQUE INDEX. Q64 mv_employee_salary_latest (employee_id) + UNIQUE INDEX. Q65 mv_orders_clean (heavy join) + secondary indexes for common filters (Topic 20). Q66 mv_page_view_hourly (hour, device) + UNIQUE INDEX. Q67 mv_region_x_month_revenue (Topic 21 pivot) + UNIQUE INDEX(region). Q68 mv_top_customers_year (year, rank) + UNIQUE INDEX. Q69 mv_customer_360_summary (customer_id) + UNIQUE INDEX (Topic 24-style). Q70 Refresh dependency order: list which MVs must refresh before others. Q71 Write a refresh script that runs in dependency order. Q72 CONCURRENTLY-safe refresh requirements: verify each MV has a UNIQUE INDEX. Q73 Compare REFRESH (locks) vs REFRESH CONCURRENTLY (online) - pick per MV. Q74 EXPLAIN ANALYZE a query against the MV (Topic 19) - index-only? Q75 Decide hourly vs daily refresh per MV; document in a comment. COMPOSED ANALYTICS VIEWS Q76 v_region_dashboard: orders, revenue, median AOV, P95 AOV (Topic 22). Q77 mv_region_dashboard + UNIQUE INDEX(region); concurrent refresh. Q78 v_cohort_retention (Topic 23 spine) layered. Q79 v_funnel_stage_counts (web_events) layered. Q80 v_delivery_sla per region (median/P95, Topic 22). Q81 v_pricing_corridor per product (P25-P75, Topic 22) + latest price (DISTINCT ON). Q82 v_customer_rfm (NTILE, Topic 16) - base layer for Topic 27 preview. Q83 v_anomaly_daily (Topic 22 P95 / Topic 23 spine) on top of mv_daily_revenue. Q84 v_top_products_per_category (Topic 16) -> mv with refresh. Q85 v_heatmap_weekday_hour (Topic 23) -> mv (small but indexed). Q86 v_audit_change_summary on record_changes. Q87 v_customer_360_relational with arrays-of-IDs (Topic 24-adjacent). Q88 v_pay_slip_summary per dept (median/P95 net, Topic 22). Q89 v_inventory_value per warehouse (latest snap x cost_price). Q90 v_revenue_decomposition new/returning per month. Q91 v_orders_with_filter_pivot (Topic 21) of status counts. Q92 v_region_x_quarter median AOV (Topic 22+21). Q93 v_dynamic_sla per region (target = prior-Q P90, Topic 22). Q94 mv_customer_360_summary (Topic 24-spirit) refreshed nightly. Q95 v_growth_metrics MoM / YoY per region (Topic 23). Q96 mv_growth_metrics + UNIQUE INDEX(region, month); test refresh. Q97 Document each MV's refresh cadence and dependency chain. Q98 Validate substitutability: live aggregate vs MV - totals match? Q99 Drop all created MVs in dependency-safe order. Q100 Drop the full stack; provide an idempotent recreate script. Interview grade, edge cases
CONCEPTUAL Q1 Designing a 3-layer view stack at scale: raw / cleaned / metrics responsibilities. Q2 View inlining limits: when the planner can't push predicates through. Q3 Materializing for query speed vs view for freshness - a decision rubric. Q4 REFRESH MV CONCURRENTLY constraints + unique-index requirement at scale. Q5 Refresh choreography for a DAG of MVs (dependency-safe ordering). Q6 Indexing MVs (Topic 20) - primary unique + secondary range + expression. Q7 Plan inspection on MV-backed dashboards (Topic 19) - index-only-scan goals. Q8 DROP CASCADE blast-radius mitigation (dependency audit). Q9 Backward-compat view evolution (versioned vN; deprecation pattern). Q10 Stale-data SLAs per consumer and how to drive refresh cadence. Q11 Hybrid: live view on top of an MV (last-N-minutes UNIONed in). Q12 Multi-grain MVs (day / week / month) with consistent rollups. Q13 Partial MV (filtered set) for hot dashboards. Q14 View security & search_path discipline at scale. Q15 Anti-pattern: deeply nested views causing replanning cost. Q16 Time-series MV refresh strategy (Topic 23) - incremental concept. Q17 Percentile MV (Topic 22) - chunked rebuild for huge tables. Q18 JSON-export MV (Topic 24) - when to ship API payload as an MV. Q19 Pivot MV (Topic 21) - wide vs long, schema stability concerns. Q20 Validation checks against MVs (totals match base) as a contract. Q21 Documentation: per MV - owner, grain, refresh cadence, dependents. Q22 View naming & namespacing (raw_/clean_/m_/mv_) - stack hygiene. Q23 Index maintenance cost on MV refresh - when to drop+recreate. Q24 Multi-tenant view layering (per-region filtered views). Q25 When NOT to materialize (small / cheap / volatile data). PRODUCTION VIEW STACKS Q26 Orders stack: raw -> clean -> enriched -> metrics (4 views) with proper dependencies. Q27 Customers stack: raw -> clean (full_name, primary city) -> enriched (latest order Topic 22). Q28 Products stack: raw -> clean -> enriched (brand+category+promo flag). Q29 Inventory stack: raw -> latest-per-(warehouse,prod) (Topic 22) -> value (x cost_price). Q30 Tickets stack: raw -> clean -> SLA per priority (median/P95, Topic 22). Q31 Pay-slip stack: raw -> clean (period date) -> summary per dept (Topic 22). Q32 Returns stack: raw -> enriched (with order/customer) -> metrics by category. Q33 Audit stack: record_changes raw -> typed -> change-summary. Q34 Web stack: page_views raw -> cleaned -> hourly (Topic 23). Q35 Calls stack: raw -> enriched (agent dept) -> SLA / hour-of-day (Topic 22+23). Q36 Cross-stack: orders + customers -> v_orders_with_customer (canonical join). Q37 Cross-stack: orders + payments (latest, Topic 22) -> v_orders_with_payment. Q38 Cross-stack: orders + shipments + delivery_days (Topic 23). Q39 Cross-stack: returns -> orders -> customers -> tier-aware metrics. Q40 Region rollup stack: stores -> region revenue/quarter (Topic 21+23). Q41 Region percentiles layer: median/P90/P95 AOV per region (Topic 22) on top of metrics. Q42 Top-N layer (Topic 16): top customers per region by lifetime spend. Q43 Cohort layer (Topic 23 + window): cohort_month + period_index 0..11. Q44 RFM layer (Topic 16 NTILE): recency/freq/monetary scores per customer. Q45 Customer-360 layer (Topic 24-spirit): joined arrays-of-IDs of latest activity. Q46 Anomaly layer (Topic 22+23): daily revenue beyond P95 flagged. Q47 Funnel layer: stage counts from web_events + drop-off ratios. Q48 Pricing-corridor layer (Topic 22): P25-P75 + latest selling price. Q49 Sales-trend layer: MoM / YoY per region (Topic 23 + window). Q50 Build an "exec metrics" leaf view that pulls from all the above. MV REFRESH CHOREOGRAPHY Q51 Convert the orders-metrics layer to MV + UNIQUE INDEX + CONCURRENTLY-safe. Q52 mv_revenue_by_region_month (region, month) with UNIQUE + range index. Q53 mv_customer_lifetime + secondary indexes (tier, region). Q54 mv_store_kpis monthly per store; refresh cadence comment in DDL. Q55 mv_ticket_sla per priority; UNIQUE INDEX + plan-check (Topic 19). Q56 mv_daily_revenue (Topic 23) gap-filled + UNIQUE INDEX(d) + plan-check. Q57 mv_inventory_latest + UNIQUE INDEX(warehouse_id, prod_id). Q58 mv_top_customers_per_region (Topic 16) + (region, rank) UNIQUE. Q59 mv_region_percentiles AOV (Topic 22) + UNIQUE INDEX(region). Q60 mv_region_x_month_revenue (Topic 21 pivot) + UNIQUE INDEX(region). Q61 mv_funnel_counts + UNIQUE INDEX(stage). Q62 mv_cohort_retention (cohort_month, period_index) + UNIQUE INDEX. Q63 mv_rfm_scores (customer_id) + UNIQUE INDEX. Q64 mv_customer_360_summary (customer_id) + UNIQUE INDEX (Topic 24-spirit). Q65 Dependency graph: list refresh order for the above MVs. Q66 Script: refresh all MVs in dependency order with CONCURRENTLY where possible. Q67 Detect MVs missing UNIQUE INDEX (would block CONCURRENTLY) - audit query. Q68 Compare REFRESH (lock) vs REFRESH CONCURRENTLY timings - concept + measurement. Q69 Hybrid view: mv_daily_revenue UNION live last-N-hour aggregate. Q70 Partial MV: only the last 90 days (Topic 23 cutoff) - speed up refresh. Q71 Multi-grain MVs (day/week/month) revenue with reconciliation checks. Q72 Validation: per MV - totals match the live aggregate (assertion query). Q73 Drop+recreate index on MV refresh to keep bloat low (concept). Q74 Refresh budgeting: which MVs fit a 5-minute SLO; which need hourly. Q75 Document each MV: owner, grain, refresh, dependents - in DDL comment. COMPOSED ANALYTICS MVS Q76 mv_region_dashboard (orders, median/P90/P95 AOV, latest order, rank) - exec strip. Q77 mv_cohort_triangle_with_ltv: cohort x period retention + cumulative revenue (Topic 23). Q78 mv_delivery_sla per region (median/P95 days + breach %, Topic 22). Q79 mv_ticket_sla_extended per priority/month (Topic 23). Q80 mv_pricing_corridor per product + latest price + drift flag (Topic 22). Q81 mv_inventory_value per warehouse + days-of-cover (Topic 23). Q82 mv_anomaly_daily revenue beyond regional P95 (Topic 22+23) for alerting. Q83 mv_funnel_drop_off per stage + per hour (Topic 23). Q84 mv_customer_rfm_segments (Topic 16 NTILE) - Topic 27 preview. Q85 mv_audit_change_jumps > 50% price-change (Topic 26 preview). Q86 mv_heatmap_weekday_hour (Topic 23) - small but indexed for UI. Q87 mv_region_x_quarter median AOV (Topic 22+21+23). Q88 mv_growth_metrics MoM/YoY per region (Topic 23). Q89 mv_customer_360_summary (Topic 24-spirit) - refreshed nightly, comment cadence. Q90 mv_pay_slip_dept_summary (median/P95 net by dept, Topic 22). Q91 mv_top_products_per_category (Topic 16) - for catalog highlights. Q92 mv_revenue_decomposition new/returning per month per region. Q93 mv_inventory_stockout_streaks per warehouse (Topic 23 + gap-and-island concept). Q94 mv_dynamic_sla_attainment (target = prior-Q P90, Topic 22). Q95 mv_calls_hourly per agent + median duration (Topic 22+23). Q96 mv_returns_root_cause per category/region (counts + refund %). Q97 mv_executive_strip (orders, median, P95, SLA%, churn-risk count, rank). Q98 Validation suite: assert mv totals = live totals for all the above. Q99 Drop-all script in dependency-safe order (audit dependencies first). Q100 Capstone: deliver a 3-layer stack (raw / cleaned / metrics) + MV at the top, with UNIQUE INDEX, refresh cadence documented, plan-checked (Topic 19), and reconciliation. Production scenarios, optimisation
CONCEPTUAL Q1 Designing the semantic / metrics layer (raw -> core -> marts -> exec). Q2 View vs MV vs summary table - a decision rubric per workload. Q3 DAG-driven refresh orchestration; idempotency and ordering guarantees. Q4 Versioned view rollout (v1 -> v2) without breaking consumers. Q5 Partial MVs (filtered hot window) + hybrid live-tail UNION. Q6 Multi-grain MV rollups (day/week/month) - consistency proofs. Q7 Incremental MV refresh - concept and constraints in Postgres. Q8 CONCURRENTLY mechanics + unique-index requirement at scale. Q9 Plan inspection for MV-backed dashboards (Topic 19); index-only goals. Q10 Index strategy on MVs (Topic 20): unique + range + expression + covering. Q11 Cascading drops: dependency audit + safe rollback strategy. Q12 SLA-driven refresh cadence: 5-min / hourly / daily tiers. Q13 Cost model for refresh under load; window selection. Q14 View aliasing & deprecation period; consumer migration plan. Q15 JSON-export MVs (Topic 24) as API products; envelope contract. Q16 Multi-tenant filtered views; row-level isolation patterns. Q17 Latency-SLO MVs (P95, Topic 22) and burn-rate alerting. Q18 Time-series MV layout (Topic 23) and partition-of-grain. Q19 Schema evolution under MVs: drop-and-recreate vs in-place. Q20 Validation contracts: per MV totals match base; alarms on drift. Q21 Documentation as data: store owner / grain / cadence in MV comment. Q22 View-stack hygiene: depth limits, naming, ownership. Q23 Building the "exec strip" as a single MV from many marts. Q24 Topic 26 dedup integration: cleaned layer hosts dedup logic (preview). Q25 Topic 27 cohort / RFM: marts vs MVs - refresh cadence implications. SEMANTIC-LAYER ARCHITECTURES Q26 Raw layer (passthrough + renames): v_raw_orders/customers/products/stores/regions. Q27 Core layer (cleaned, typed, deduped): v_core_orders/customers/products. Q28 Mart layer: v_mart_revenue_by_region_month, v_mart_customer_lifetime. Q29 Exec layer: v_exec_region_strip (orders, median/P90/P95 AOV, latest). Q30 Cross-domain customer mart: orders + reviews + tickets + payments latest (Topic 22). Q31 Product mart: brand + category + promo + margin + latest price (Topic 22). Q32 Inventory mart: latest snapshot per SKU + value + days-of-cover (Topic 22+23). Q33 Web-events mart: sessions + funnel + heatmap (Topic 23). Q34 SLA mart: delivery + ticket + call SLA per priority/region (Topic 22). Q35 Pricing mart: corridor (P25-P75) + drift + latest selling price. Q36 Cohort mart: cohort x period retention + cumulative LTV (Topic 23, Topic 27 preview). Q37 RFM mart: NTILE recency/freq/monetary per customer (Topic 16, Topic 27 preview). Q38 Audit mart: change history + > 50% jumps + actor (Topic 26 preview). Q39 Region rollup mart: stores aggregated to region with percentiles. Q40 Multi-grain rollup mart: day -> week -> month with reconciliation. Q41 Anomaly mart: daily P95/P99 flags (Topic 22+23). Q42 JSON-export mart (Topic 24): per region exec strip as nested doc. Q43 Time-series mart (Topic 23): date -> rev + MA + MoM/YoY. Q44 Funnel mart per channel/hour (Topic 23). Q45 Pricing-corridor JSON mart (Topic 24) for the catalog API. Q46 Customer-360 relational mart (Topic 24-adjacent) - IDs of latest activity. Q47 Lifecycle-stage mart per customer per month. Q48 Reactivation mart: dormancy -> reactivation per month. Q49 Heatmap mart weekday x hour per device (Topic 23). Q50 Compose the full semantic layer as a runnable script. REFRESH ORCHESTRATION & MV PIPELINES Q51 Build the refresh DAG (dependency edges) for every MV created so far. Q52 Generate a refresh script that runs MVs in topological order. Q53 Mark each MV CONCURRENTLY-eligible (UNIQUE INDEX present)? Audit query. Q54 Hybrid MV + live-tail: mv_daily_revenue UNION live last-N-hour aggregate. Q55 Partial MV: only last 90 days of mv_daily_revenue (Topic 23 cutoff). Q56 Chunked refresh design for huge percentile MVs (Topic 22). Q57 Multi-grain MV trio (day/week/month) revenue + reconciliation assert. Q58 Time-budget refresh planner - group MVs by cadence tier. Q59 Idempotent rebuild for a date range - DROP + CREATE + REFRESH dance. Q60 Detect dependency cycles in the view DAG (audit, concept). Q61 Versioned MV rollout v2 alongside v1; deprecation window. Q62 Plan inspection (Topic 19) for every consumer query - index-only check. Q63 Index strategy on each MV (Topic 20): unique + covering + expression. Q64 Drop-and-recreate vs ALTER MATERIALIZED VIEW - when each. Q65 Refresh failure handling: alarms, partial-state safety. Q66 Reconciliation suite: mv totals = base totals (assertion queries). Q67 SLA report per MV: freshness (refresh-age) + size + index health. Q68 Cost forecasting per refresh tier (5-min / hourly / daily). Q69 Refresh-window throttling for resource contention (concept). Q70 Build mv_exec_strip from many marts + UNIQUE INDEX(region). Q71 Build mv_customer_360 + UNIQUE INDEX(customer_id) + cadence comment. Q72 Build mv_anomaly_alerts (Topic 22+23) + UNIQUE INDEX(d, region). Q73 Build mv_funnel_stage_hourly + UNIQUE INDEX(stage, hour). Q74 Build mv_pricing_corridor + UNIQUE INDEX(prod_id). Q75 Wire the full refresh DAG: one script, dependency-ordered, idempotent. PRODUCTION DELIVERY SYSTEMS Q76 Exec dashboard delivery: mv_exec_region_strip + JSON-export view (Topic 24). Q77 SLA monitoring delivery: mv_delivery_sla + mv_ticket_sla + dashboards. Q78 Pricing governance delivery: mv_pricing_corridor + drift alerts. Q79 Inventory operations delivery: mv_inventory_value + cover trend + stockout streaks. Q80 Funnel analytics delivery: mv_funnel_stage_hourly + per-channel breakdown. Q81 Cohort retention delivery: mv_cohort_triangle_with_ltv (Topic 23). Q82 RFM delivery: mv_customer_rfm + segment counts (Topic 16, Topic 27 preview). Q83 Anomaly delivery: mv_anomaly_daily + alert payload JSON (Topic 24). Q84 Audit-compliance delivery: mv_audit_change_jumps + actor + table summary (Topic 26 preview). Q85 Heatmap product delivery: mv_heatmap_weekday_hour normalized (Topic 23). Q86 Region growth delivery: mv_growth_metrics MoM/YoY + rank + alerts. Q87 Customer-360 delivery: mv_customer_360_summary + JSON export (Topic 24). Q88 Pay-slip equity delivery: mv_pay_slip_dept_summary (Topic 22). Q89 Returns root-cause delivery: mv_returns_root_cause per category/region. Q90 Dynamic-SLA delivery: mv_dynamic_sla_attainment (target = prior-Q P90, Topic 22). Q91 Real-time-ish ops board: hybrid MV + live tail (concept). Q92 Multi-tenant region delivery: filtered views per region. Q93 Versioned semantic layer v2: rollout + deprecation script. Q94 Validation suite: mv <-> base reconciliation alerts. Q95 Refresh SLA report: per MV freshness + size + dependents. Q96 Catalog API delivery: pricing + promo MV (Topic 24 JSON envelope). Q97 Region exec JSON: mv_region_dashboard -> JSON nested doc (Topic 24). Q98 Lifecycle delivery: mv_lifecycle_stage_monthly per customer. Q99 End-to-end semantic-layer script: raw -> core -> marts -> exec -> JSON exports. Q100 Capstone: the production semantic-layer + MV refresh DAG (raw/core/marts/exec, unique indexes, CONCURRENTLY where eligible, reconciliation, JSON exports), with cadence and dependents documented in MV comments.