learndatalogtoday icon indicating copy to clipboard operation
learndatalogtoday copied to clipboard

Different results for same where-conditions in different order.

Open ivan-klass opened this issue 10 years ago • 0 comments

As declared in the beginning of tutorial, logical meaning of :where [ __a_clause__ ] [__b_clause__] is same as :where [ __b_clause__ ] [__a_clause__]. However, this rule doesn't work in following task:

http://www.learndatalogtoday.org/chapter/4

Task 2 : Find all available attributes, their type and their cardinality. ...

This is considered as correct query:

[:find ?attr ?type ?card
 :where
 [_ :db.install/attribute ?a]
 [?a :db/valueType ?t] 
 [?a :db/cardinality ?c]
 [?a :db/ident ?attr]
 [?t :db/ident ?type]
 [?c :db/ident ?card]]

But when simply changing the order of condition clauses - result changes and warning appears. Example:

[:find ?attr ?type ?card
 :where
 [?a :db/valueType ?t] 
 [?a :db/cardinality ?c]
 [?a :db/ident ?attr]
 [?t :db/ident ?type]
 [?c :db/ident ?card]
 [_ :db.install/attribute ?a]]

In my case it was very confusing - because I managed to compose the query like in last example, and finally had to "give up".

ivan-klass avatar Jan 20 '15 05:01 ivan-klass