Relix

Manual

Problem solving

What kind of problem is this, and which parts of the language solve it — a recipe book for readers who know the language.

This manual is for readers who already know the language and want to know which parts of it to reach for. The reference answers what does this operator do?; this manual answers the question that comes first — what kind of problem is this? — and then hands you a recipe. Every problem in it is classified the same way, by three questions asked before any code is written:

  1. What is the grain? Finish the sentence "one row per ___".
  2. What is the quantifier? The word in the question that decides the logic — which, how many, the most, any, none, every, connected…
  3. What makes the data difficult? Nested, dirty, NULL-heavy, unbounded, federated, or out of step in time.

The answers give a problem its coordinate, and the coordinate points at a recipe. Each recipe carries its coordinate as one line under the title, in a fixed format that a reader reads and the recipe finder is generated from.

Download this manual as a PDF

The method

The four moves that turn a question into a query, in order.

ChapterWhat it teaches
Grain firstDecide "one row per ___" before choosing an operator
Find the quantifierThe word in the question that fixes the logic
Decompose into viewsBuild the answer as a pipeline of named relations
Check your answerThe checklist that tells runs from right

Recipes: selection and summary

RecipeFor
Which rows, and which columnsFiltering rows and choosing columns, keeping the grain
How many, how much, per whatTotals and counts per group, running totals, time buckets

Recipes: ranking

RecipeFor
The most, the top N, the latestThe top rows, the latest per key, and ties

Recipes: existence and absence

RecipeFor
Has at least oneKeeping an entity when a matching row exists
None, never, missingKeeping an entity with no match; what a reference list lacks

Recipes: every and only

RecipeFor
Every: related to all of a set, or all rows pass a testRelated to all of a set, or every row passing

Recipes: comparison

RecipeFor
What changed, what differsReconciling two snapshots, or two systems

Recipes: graphs

RecipeFor
Things that belong togetherUndirected groups — duplicates, households, rings
Reachable, how far, and by what routeDirected reachability, distance, and the optimal route
When the rule is recursiveGeneral recursion when the two-column form will not do

Recipes: time

RecipeFor
As of, during, overlappingThe value as of a moment; overlapping periods
In a row, per visit, gapsSessions, gaps, and each row's neighbour in order

Recipes: choosing and solving

RecipeFor
The best combination within limitsThe best subset under a budget
What value makes this trueFilling the one value that satisfies an equation
Enough cases to coverA covering test suite over a parameter space

Recipes: reshaping

RecipeFor
As columns, as a list, as a treePivoting, nesting, unnesting, folding to a tree

Recipes: explaining

RecipeFor
Why is this row here, where did it come fromReifying a result's lineage and reading it

Recipes: sampling

RecipeFor
A random, representative subsetA reproducible random sample

Recipes: iteration

RecipeFor
Iterate until it settlesConverging, or simulating rounds, replacing state each time

Case studies

Problems that cross several classes, each classified out loud before any code.

Case studyClasses it crosses
Fraud ringsExistence + graph + explanation
Family historyGraph + time
Inventory allocationSummary + optimization
SLA breachesTemporal alignment + sequence
Reconciling two systemsComparison + federation
Test planningGeneration

Engineering the solution

Making a correct query run well, and moving a solution into a program.

ChapterCovers
Engineering the solutionReading a plan, what stops a pushdown, bounding a generator, budgets, working offline, moving into Java

When Relix is not the tool

Where to stop — the problems it does not do, and the ones it does that you might think it does not.

ChapterCovers
When Relix is not the toolRow-at-a-time thinking forced into sets, recursion where an operator would do, and what is out of range

Recipe finder

IndexBy
Recipe finderQuestion word, operator, and class