[Datalog] Querying attributes in the Learn Datalog Today tutorial

I’m reading the Learn Datalog Today tutorial, kindly linked by @Siferiax and I have a few questions.

It’s a little odd that the author doesn’t show their Datomic database contents, as it could make the explanations more understandable, so I have to figure out what the database structure is myself to see the full picture.

I cannot request it directly tho:

[:find ?e ?a ?v ?tx
 [?e ?a ?v ?tx]

— as I get an error like:

Oh snap!
:db.error/insufficient-binding Insufficient binding of db clause: [?e ?a ?v ?tx] would cause full scan

However I can do this:

[:find ?e ?a
 [?e :db/ident ?a]


which (presumably) lists all the tuples containing the :db/ident attribute. Great, and now I want to see just one - the :person/name:

[:find ?e
 [?e :db/ident :person/name]

which gives me 68:

Now I want to select all the attributes that have :person/name as their value:

[:find ?e ?a
 [?e ?a :person/name]

but this one returns empty result. Why is that?

I don’t know the reason for the empty result, but I would guess that such a query would also cause a full scan, therefore it fails. You can still get the desired result by using one extra clause, either of:

  • [?a :db/ident]
  • [?e :db/ident]
  1. Database structure is 1 table of tuples.
  2. As stated in the tutorial :db/ident gives you a list of available attribute.
  • in other words, the value of :db/ident is an attribute name
  • and in another way there is only one attribute which lists available attributes: :db/ident
  1. I suspect the problem is between database attributes (like :db/ident), which I would guess are system attributes and custom attributes, as defined by the user.

Fiddling around a little it seems the structure is as:
[68 10 :person/name]
Perhaps this is why it is breaking?

More fiddling later…
I think it has to do with using system attributes.
It seems attribute have attributes, have attributes. Or something like that.
I would just discard using any :db/ attribute as this is not something to use within logseq.
To illustrate: