Skip to main content

Search

Search problems, hooks, and pages

Back to About

Database Decision Helper

built with: Pure scoring functions · client-only

Every filter chip re-runs a pure recommend() function over four databases and re-renders the whole scorecard grid, with zero network round-trips.

A scorecard, not a wizard

Most "which database should I use" tools are a linear quiz ending in one report screen. This one keeps all four databases visible the whole time: a left rail of category-grouped questions (data shape, relationships, consistency, query patterns, workload, scale, schema flexibility, expiration, caching) feeds a 2x2 grid of cards that update their fit tier live as each answer is picked.

Each answer maps to one or more RequirementSignals, and buildDashboardCards(signals) turns the current signal set into the grid state on every change — there is no draft state that only resolves at the end.

Recommendation is a pure function over signals

recommend(signals) scores each database and explains why it fits or does not, entirely client-side, so toggling a filter is instant regardless of connection.

Once a clear signal set exists, the full report (tradeoffs, alternatives, learning topics) renders inline below the grid rather than replacing it, so the detail and the live comparison stay on screen together.

// src/lib/database-decision-helper/recommend.ts
export function recommend(signals: RequirementSignal[]): Recommendation {
  return DATABASES.map((db) => ({
    db,
    tier: scoreFit(db, signals), // strong | possible | poor | not-suitable
    reasoning: explainFit(db, signals)
  }));
}

Answers carry real code, not just labels

A question option like "yes, I need multi-document transactions" renders an actual transaction snippet inline through the same CodeBlock component the rest of the app uses for machine-coding problems, so the tradeoff is shown as working syntax rather than a sentence.

A glossary panel (a sidebar on desktop, a sheet on mobile) surfaces the specific learning topics the current recommendation touched, so the tool doubles as a jumping-off point back into the study content instead of a dead end.

Important

Gotcha

Because every database's tier recomputes on every answer, the fit logic stays a pure function of the full signal set rather than an incremental patch — recommend() always scores from scratch, which is what keeps toggling a filter off exactly as correct as toggling it on.

Where it lives in the repo

  • src/components/database-decision-helper/dashboard-view.tsx
  • src/components/database-decision-helper/filter-rail.tsx
  • src/components/database-decision-helper/db-card.tsx
  • src/components/database-decision-helper/recommendation-report.tsx
  • src/lib/database-decision-helper/recommend.ts
  • src/lib/database-decision-helper/dashboard-cards.ts
  • src/data/database-decision-helper/questions.ts