This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-05
Channels
- # announcements (1)
- # babashka (6)
- # beginners (37)
- # clojure (4)
- # clojure-europe (6)
- # clojure-india (3)
- # clojure-spec (6)
- # clojured (1)
- # clojurescript (14)
- # datalog (5)
- # gratitude (1)
- # helix (3)
- # hyperfiddle (1)
- # interop (6)
- # leiningen (2)
- # off-topic (142)
- # other-lisps (2)
- # pathom (20)
- # releases (1)
- # rewrite-clj (4)
- # shadow-cljs (5)
- # tools-deps (3)
Hello everybody, I'm playing a bit with Datalog (with Datascript) on some existing code. This code is sort of "SQL oriented" and I have some difficulties to escape this mental model. My data is a "test result" and looks like this right now.
{
:team-id "ABDEF" ;; identity of the team for which the test ran : foreign key
:test {
:title "My first test" ;; identity of the test
:campaign-name "My first campaign" ;; identity of the campaign containing the test : foreign key
}
;; data of the test result
}
From my current understanding of Datalog queries, it seems it would be easier to transform my data to create real "refs" in the data.
{
:team { :team/id "ABDEF" }
:test {
:title "My first test" ;; Should be renamed :test/title in the process...
:campaign {:campaign/name "My first campaign"}
}
;; data of the test result
}
Is this the "Datalog way" of doing things ?Yup, the 2nd data structure seems DataScript-friendly to me 🙂
But your issue is more related to the data model of DataScript and its transactions language than to Datalog.
More precisely, the above code will write correctly to DataScript if:
1. :team
is a cardinality-one, ref-typed attribute from TestResult to Team (you might want to rename to :test-result/team
)
2. :test
is a cardinality-one, ref-typed attribute from TestResult to Test (you might want to rename to :test-result/test
)
3. :campaign
is a cardinality-one, ref-typed attribute from Test to Campaign (you might want to rename to :test/campaign
)
4. :team/id
is a :db.unique/identity
attribute for identifying a Team
5. :title
is a :db.unique/identity
attribute for identifying a Team (you might want to rename to :test/title
)
6. :campaign/name
is a :db.unique/identity
attribute for identifying a Campaign
I totally missed the point on the namespace "test-result" for team and test, but you're absolutely right. Thanks for the detailed response !