Skip to main content

Data Bench

Challenge on lesson: Checkpoint: Data Layer

Write THREE functions. 1) joinPlan(query) — given a desired query description, return the join type: "users and their tasks (skip users with none)" => "inner"; "all users with task counts (zero included)" => "left"; "all tasks with their tag names" (many-to-many) => "inner-two" (two joins); anything else => "none". 2) txDecision(steps, hasFailureRisk) — return "transaction" when there are 2+ write steps OR hasFailureRisk; "single" when exactly one write step and no risk; "readonly" when zero write steps. 3) countQueries(taskCount, pattern) — pattern "n+1" => taskCount + 1 queries; "join" => 1; "in-clause" => 2.

Difficulty: intermediate

Back to lesson: Checkpoint: Data Layer