datalog

refset 2022-01-31T17:17:21.453669Z

XT doesn't support wildcard attribute vars, which is needed for a single not to be sufficient, so you'd either need a not per attribute (e.g. generating verbose queries), or you can define orphan? as a custom function that executes an inner query per attribute: https://gist.github.com/refset/25d8ae03c69993831c9c23cf7e12a537

๐Ÿ‘ 1
quoll 2022-02-01T11:06:42.147839Z

Iโ€™ve never needed to before! (Outside of unit tests)

๐Ÿ˜„ 1
quoll 2022-01-31T18:13:16.629679Z

This is where it gets tricky between databases. For instance, Asami has several options, but for this query it could just use: :find ?e :where [?e] (not [_ _ ?e])

๐Ÿ’ฏ 2
refset 2022-01-31T21:22:59.870529Z

oh cool, I don't think I've seen anyone reduce a triple clause to merely [?e] before ๐Ÿ™‚

denik 2022-01-31T02:08:02.449029Z

whatโ€™s the best way to find entities without db.type/ref relationships? in a graph these could be called orphan nodes.

quoll 2022-01-31T05:06:42.280129Z

Thinking of Datomic: :find ?e :where [?e ?a ?v] [?a :db/ident] (not [?o ?r ?e] [?r :db/ident]) The :db/ident statements are because unbound patterns make Datomic nervous. (Iโ€™m not sure if it's needed in the not expression)