Trying to understand the use of not and not-join in queries.
Multiple not Clauses
The following raises:db.error/insufficient-binding [?release] not bound in not clause:
(d/q '[:find (count ?artist) .
:where [?artist :artist/name]
(not
[?release :release/artists ?artist]
[?release :release/year 1970])]
db
"John Lennon")
I’m trying to understand why via the description in How Not Clauses Work:
One can understand not clauses as if they turn into subqueries where all of the variables and sources unified by the negation are propagated to the subquery. The results of the subquery are removed from the enclosing query via set difference.
Subqueries of what? Of the set of results returned by the query without the not clause? Would it be correct to understand that because the query without the not clause does not contain ?release, the not clause cannot refer to it?
not and not-join
The following gives 4124:
(d/q '[:find (count ?artist) .
:where [?artist :artist/name]
[?release :release/artists ?artist]
(not
[?release :release/year 1970])]
db
"John Lennon")
While this gives 3263:
(d/q '[:find (count ?artist) .
:where [?artist :artist/name]
(not-join [?artist]
[?release :release/artists ?artist]
[?release :release/year 1970])]
db
"John Lennon")
It seems to me the two queries are the same–where do they differ?