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:
- What is the grain? Finish the sentence "one row per ___".
- What is the quantifier? The word in the question that decides the logic — which, how many, the most, any, none, every, connected…
- 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.
The method
The four moves that turn a question into a query, in order.
| Chapter | What it teaches |
|---|---|
| Grain first | Decide "one row per ___" before choosing an operator |
| Find the quantifier | The word in the question that fixes the logic |
| Decompose into views | Build the answer as a pipeline of named relations |
| Check your answer | The checklist that tells runs from right |
Recipes: selection and summary
| Recipe | For |
|---|---|
| Which rows, and which columns | Filtering rows and choosing columns, keeping the grain |
| How many, how much, per what | Totals and counts per group, running totals, time buckets |
Recipes: ranking
| Recipe | For |
|---|---|
| The most, the top N, the latest | The top rows, the latest per key, and ties |
Recipes: existence and absence
| Recipe | For |
|---|---|
| Has at least one | Keeping an entity when a matching row exists |
| None, never, missing | Keeping an entity with no match; what a reference list lacks |
Recipes: every and only
| Recipe | For |
|---|---|
| Every: related to all of a set, or all rows pass a test | Related to all of a set, or every row passing |
Recipes: comparison
| Recipe | For |
|---|---|
| What changed, what differs | Reconciling two snapshots, or two systems |
Recipes: graphs
| Recipe | For |
|---|---|
| Things that belong together | Undirected groups — duplicates, households, rings |
| Reachable, how far, and by what route | Directed reachability, distance, and the optimal route |
| When the rule is recursive | General recursion when the two-column form will not do |
Recipes: time
| Recipe | For |
|---|---|
| As of, during, overlapping | The value as of a moment; overlapping periods |
| In a row, per visit, gaps | Sessions, gaps, and each row's neighbour in order |
Recipes: choosing and solving
| Recipe | For |
|---|---|
| The best combination within limits | The best subset under a budget |
| What value makes this true | Filling the one value that satisfies an equation |
| Enough cases to cover | A covering test suite over a parameter space |
Recipes: reshaping
| Recipe | For |
|---|---|
| As columns, as a list, as a tree | Pivoting, nesting, unnesting, folding to a tree |
Recipes: explaining
| Recipe | For |
|---|---|
| Why is this row here, where did it come from | Reifying a result's lineage and reading it |
Recipes: sampling
| Recipe | For |
|---|---|
| A random, representative subset | A reproducible random sample |
Recipes: iteration
| Recipe | For |
|---|---|
| Iterate until it settles | Converging, or simulating rounds, replacing state each time |
Case studies
Problems that cross several classes, each classified out loud before any code.
| Case study | Classes it crosses |
|---|---|
| Fraud rings | Existence + graph + explanation |
| Family history | Graph + time |
| Inventory allocation | Summary + optimization |
| SLA breaches | Temporal alignment + sequence |
| Reconciling two systems | Comparison + federation |
| Test planning | Generation |
Engineering the solution
Making a correct query run well, and moving a solution into a program.
| Chapter | Covers |
|---|---|
| Engineering the solution | Reading 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.
| Chapter | Covers |
|---|---|
| When Relix is not the tool | Row-at-a-time thinking forced into sets, recursion where an operator would do, and what is out of range |
Recipe finder
| Index | By |
|---|---|
| Recipe finder | Question word, operator, and class |