Fork me on GitHub
#datalog
<
2023-06-02
>
greg13:06:53

How to express in datalog that the entity is referenced by some other entity (but I don't need to capture info about referencing entity)?

Björn Ebbinghaus18:06:16

A reference is a fact like any other. You can check if the fact is present.

[?person :person/children _]
Matches if ?person has a fact with attribute :person/children. Meaning ?person has a reference to a child. (You can elide trailing _, so you can write [?person :person/children]) Other way round:
[_ :person/children ?child]
Matches if ?child is referenced by some entity through the :person/children attribute.

👍 1