mium
Drop #28··Advanced Query
advanced query (datalog)

Advanced Query (Datalog)

A Simple Query filters one property. Datalog links many — across blocks, with derivation and aggregation, into a multi-criteria report.

Team Mut··builds mium··Falktron, Oelde
tl;dr··30 sek
  • ··Datalog is a rule language: you describe what should be true, not how the search runs.
  • ··Rules link blocks across several criteria, derive new facts and aggregate — one filter line cannot do this.
  • ··Once defined, the rule becomes a reusable view — the report builds itself.
audio··3:00
▶ Audio coming soon
Transcript

What if your report did not have to be clicked together from ten views, but grew from a single rule — a rule that describes what counts and recomputes on its own? Over the next few minutes you will hear where the filter line ends and where Datalog begins.

A Simple Query filters one property and becomes a view. That is enough as long as you check one thing. But the moment you want to connect two — open tasks from a quarter's meetings, grouped by project — the filter line runs out. It checks blocks one by one against fixed criteria; it links nothing, derives nothing, adds nothing up.

Datalog turns this around. You do not describe the search path, you describe the goal. You say what should be true and leave the how to the engine. That is the heart of any declarative language, and database research has documented the advantage consistently since the foundations of Datalog theory.

A rule has two parts. One part says which quantity you want to see. The other lists the conditions, line by line. Variables connect the lines — when the same variable appears more than once, that is a join, a bridge across blocks. This is exactly where a filter line turns into a connected report.

Three building blocks carry you far. First, the rule describes the goal, not the path. Second, every condition line is one criterion, and shared variables connect them into a join. Third, aggregates condense the result set — you count, sum, group, and many blocks become one number per group.

This power has a cost. An unbounded or recursive rule can traverse the whole store several times. Set limits, check the speed, and save a rule as a standing view only once it stays fast enough. And without clean properties no rule will hold — data hygiene stays the quiet precondition.

The honest question at the end: how many of your reports do you rebuild every week because they link several criteria no filter line can hold? If the figure is high, the steeper learning curve pays off. Described once as a rule, your second brain builds the report — and keeps it current while you think.

reels··3–15 sek
6.1K
Rule, not filter
9.3K
Join across blocks
11.7K
count··sum··group
14.2K
The report builds itself

A Simple Query filters one property and becomes a view. But the moment you want to connect two things — open tasks from a quarter's meetings, grouped by project — the filter line runs out. Datalog begins exactly there: you describe the relationship as a rule, and mium derives the rest.

Where the filter line ends

A filter line checks blocks one by one against fixed criteria. It cannot link across blocks, derive nothing and add nothing up. Otherwise you click multi-criteria reports together by hand from several views — and maintain them the same way. Datalog turns this around: one rule that describes relationships, and an engine that evaluates it.

Anatomy of a rule

A Datalog rule has two parts: :find says which quantity you want to see, :where lists the conditions — one per line. Variables like ?task connect the lines; when the same variable appears more than once, that is a join.

[:find ?task
 :where
 [?task "type" "task"]
 [?task "status" "offen"]
 [?task "von-meeting" ?m]
 [?m "tag" "q3"]]
;; offene Aufgaben aus Q3-Meetings — ein Join über ?m

5 building blocks for Advanced Query

  1. The rule describes the goal (:find), not the search path — you say what, not how.
  2. Every :where line is a condition; shared variables connect them into a join.
  3. Aggregates condense: count, sum, max, min, avg across the result set.
  4. A rule is reusable — name it, and it becomes a view for the whole team.
  5. Set limits: recursive or unbounded joins need a limit, otherwise the evaluation gets expensive.

Example: counting open tasks per project

[:find ?projekt (count ?task)
 :where
 [?task "type" "task"]
 [?task "status" "offen"]
 [?task "projekt" ?projekt]]
;; ein Report: pro Projekt die Zahl offener Aufgaben

Before/After — Simple Query vs. Datalog

CapabilitySimple QueryDatalog
Criteriaone propertyany number
Link across blocksnoyes (join over variables)
Derive / aggregatenocount··sum··group
Reusableas a viewas a named rule
Learning curveminutessteeper, but more powerful

An honest question

How many of your reports do you rebuild every week because they link several criteria that no filter line can hold? The answer decides whether Datalog's steeper learning curve pays off for you — or whether a Simple Query is already enough.

Describe what counts — mium computes the rest.
One rule, and your second brain builds the report — and keeps it current while you think. No export, no clicking together; a companion that understands your criteria.
Reserve your slot··free of cost →
Reserve your slot··free of cost →
The Spring School has concluded. See Day 93 → Play the game →