Startseite
Slot sichern →
BRIEF··

Datalog Patterns Cookbook··5 recipes for mium power users

EXECUTIVE SUMMARY

What if the answers to recurring vault questions lay not in laborious manual work, but in five copy-ready queries you parameterise once? The cookbook brings down the effort for standard evaluations — open deadlines, central nodes, audit trail, tag aggregation, orphans — from minutes of manual searching to one executed query, with no new software and without learning Datalog from the ground up. The prerequisite is property discipline, not a licence budget.

−80 %
Time per standard evaluation
5
Reusable recipes
0
Orphan rate after sweep
₹0
Toolchain cost
≈ 30 min
Onboarding per person
≥ 80 %
Property coverage needed
RISKS
  • Without property and namespace discipline all five recipes return empty sets instead of insight — the groundwork on the vocabulary is a prerequisite, not a side effect.
  • Inconsistent date and tag formats break filters silently, with no error message — faulty silence is more dangerous than a loud abort.
  • The orphan detector with not-join scales poorly — run interactively on large vaults it blocks the session instead of running overnight.
DECISION
Recommendation — establish the five cookbook recipes as a shared query library across the team: anchor the deadline filter, backlink hubs and orphan detector as recurring views, bring property and tag-namespace discipline forward as a prerequisite, and take expensive not-join runs out of the interactive session via cron.

This cookbook is meant for mium power users and developer profiles who have already brushed against [[advanced-query-datalog]] and are looking for concrete, copy-ready examples. Five recipes, each self-contained — anyone who needs only the orphan detector may jump straight to recipe 5. Datalog itself is a logic programming language from the 1970s; Rich Hickey rediscovered it with Datomic (Cognitect, since 2012) for practical everyday database work. mium uses a Datalog dialect to query its own block index.

Recipes

The five recipes are independent of one another. Cherry-pick what you need, or read linearly — both orders work. Every recipe has: a problem, a query, and optionally a gotcha callout.

Recipe 1··Open tasks with a deadline in the current quarter

The standard sprint question: which tasks are open and must be delivered by the end of the quarter? The query filters on `frist::` within the Q window and `status:: offen`, and returns the owner.

[:find ?block ?frist ?owner
 :where [?block :frist ?frist]
        [?block :status "offen"]
        [(>= ?frist "2026-04-01")]
        [(<= ?frist "2026-06-30")]
        [?block :owner ?owner]]

Recipe 2··Top 10 backlink hubs

Which blocks are referenced most often? The top 10 by incoming `:links-to` edges are the central nodes of your vault — often terms, persons, projects.

[:find (count ?backlink) ?target
 :where [?backlink :links-to ?target]
 :order-by [(count ?backlink) :desc]
 :limit 10]

Recipe 3··Audit trail of a block

Who changed what, and when, on a block? The query reads the transaction history in reverse for a given block ID and returns `tx`, `attr`, `value` and the `added` flag.

[:find ?tx ?attr ?value ?added
 :where [?block :db/id "<((uuid))>"]
        [?tx :tx/affected-block ?block]
        [?tx :tx/attr ?attr]
        [?tx :tx/value ?value]
        [?tx :tx/added ?added]]

Recipe 4··Cross-vault tag aggregation

How often does each client tag occur across all vaults? The query groups on `tags::` with the namespace prefix `#kunde-` and returns a sorted frequency list.

[:find (count ?block) ?tag
 :where [?block :tags ?tag]
        [(re-pattern "^#kunde-") ?tag]
 :group-by ?tag
 :order-by [(count ?block) :desc]]

Recipe 5··Orphan note detector

Which notes have no incoming backlinks and are not archived? These orphans are the dead ends of the vault — candidates for tidying up, linking or archiving.

[:find ?block ?title
 :where [?block :title ?title]
        [?block :archiv? false]
        (not-join [?block]
          [?other :links-to ?block])]

When these recipes do NOT fit

Datalog queries are not a universal instrument. Three situations in which these recipes do not hold:

  1. Full-text search in the block content — Datalog filters on properties and edges, not on prose. For “find every block that contains `Auftragsbestätigung` in its text”, the mium full-text index is the right instrument, not a Datalog query.
  2. Very unstructured vaults with no property discipline — all five recipes assume that `frist::`, `status::`, `owner::`, `tags::` are maintained consistently. In a vault where 80 % of blocks carry no properties, the queries return empty sets, not insight. Property discipline is groundwork, not a side effect.
  3. Ad-hoc explorations with an unclear question — Datalog rewards precise questions. Anyone who merely wishes to “have a look at what is in the vault” gets there faster with the graph view or backlink browsing than with a query that still has to be designed.

An honest question

Which of the five recipes fit for you, and which ran into the void? If you put one of them into production: what did you parameterise differently — shifted the Q window, changed the tag namespace, raised the limit? And if none fit: where did we miss the gap? Cookbook recipes live by rubbing up against real vaults — feedback on which recipe #6 is missing here is most welcome. Further on in this wave: [[advanced-query-datalog]] for the language fundamentals, [[simple-query]] for the gentler entry without Datalog syntax.

Audit ID: BRF-datalog-cookbook-v1.0Submitted: 2026-06-23··Falktron GmbH, Oelde
The Spring School has concluded. See Day 93 → Play the game →