Or Clauses
Pattern clauses in :where are implicitly joined with AND — every clause must match. To express OR logic, Datomic Datalog provides or and or-join.
or
or succeeds when at least one of its branches matches. All branches must use the same set of variables. Let's find Pokemon that are Fire or Water type:
Try adding a third branch for "Electric".
You can also use or to match against multiple values of the same attribute — here we find pure Fire-type or pure Water-type Pokemon by adding a second clause that rules out dual types:
or-join
or-join works like or but you declare explicitly which outer variables each branch must bind. This is required when branches introduce different local variables.
Here we find Pokemon that are either Electric-type or have a speed above 100. The second branch introduces ?speed which only exists inside that branch, so plain or would not work:
The [?e] in or-join declares that ?e is the only variable that must unify with the outer query. ?speed is a local variable that lives only inside its branch.
Try: Add a third or branch for "Electric" in the first query. Or modify the or-join query to find Pokemon that are Ground-type or have attack above 120.