datalog

greg 2023-06-02T13:47:53.606809Z

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 Ebbinghaus 2023-06-04T18:54:16.193479Z

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