This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-08
Channels
- # aws (21)
- # beginners (62)
- # boot (29)
- # chestnut (1)
- # cider (110)
- # cljs-dev (37)
- # clojure (93)
- # clojure-berlin (1)
- # clojure-dev (10)
- # clojure-greece (4)
- # clojure-italy (5)
- # clojure-new-zealand (1)
- # clojure-spec (6)
- # clojure-uk (46)
- # clojurebridge (1)
- # clojurescript (54)
- # cryogen (1)
- # cursive (22)
- # datomic (72)
- # emacs (2)
- # events (3)
- # flambo (1)
- # hoplon (88)
- # jobs (6)
- # juxt (51)
- # lein-figwheel (1)
- # leiningen (3)
- # lumo (12)
- # mount (4)
- # off-topic (3)
- # onyx (3)
- # pedestal (4)
- # portkey (27)
- # re-frame (13)
- # reagent (1)
- # ring (4)
- # rum (2)
- # uncomplicate (1)
- # unrepl (3)
I’m looking for some feedback on our datomic schema. anybody can give us some guidance? schema & questions here: https://gist.github.com/kommen/a902e4c5bfef1395e69a617d1cb427ac
@kommen I would personally favour the first approach and use :db/isComponent
on the profile refs. Disclaimer: I am new to Datomic, so take my word with a grain of salt.
Lately I have been using the “document” analogy to help me decide if i should use :db/isComponent
. I ask myself: “if I were to represent this entity as a document (e.g. in a document-oriented database), would I put this sub-entity in the document as well?”
This is basically asking “is this other entity (profile) a part of / a component of my entity (person)?” (quite naturally)
or “does a Profile have an existence of its own, or does it only exist as a part of some other entity?”
I am not sure these are the semantics that were intended for :db/isComponent
, but that’s how I have been using it so far
@favila made a remark to me the other day which is related to what you are asking now
I was asking if it made sense to add a :db/unique
constraint on attributes which have :db/isComponent
. It seemed to me that these should always be unique, and so that :db/isComponent
entailed the :db/unique
constraint
he pointed out that it entailed an even stronger constraint: an entity that is referenced by some attribute with :db/isComponent
should not be referenced by any other attribute in the database
Np 🙂 By the way on :profile/owner
, I tend to avoid polymorphic references like this because they’re harder to validate
@hmaurer @kommen that is correct, entities reachable by an isComponent attr should not be reachable (by forward references) any other way
@favila out of curiosity, what is your opinion on polymorphic refs? (however you define “polymorphic”, since there isn’t a clear notion of “entity type” in Datomic). Is it something you try to avoid? Or do you not pay particular attention at it?
there's a distinction between entity-level validity/expectation constraints for the entities in the db, and an explicit type marker is necessary for sanity here
and what a program does with the map view of this, which seems to be more interested in attrs and sets of attrs than types
@favila that’s a similar philosophy to clojure.spec I assume? The meaning of attributes should be independent of the aggregates in which they’re used
Essentially. I just want to make sure no one misinterprets me to think that {:entity-type "earthquake" :magnitude 7} {:entity-type "decimal-number" :magnitute 2}
is ok
out of curiosity, have you written a small lib internally for pre-processing data being transacted to datomic? (validation, etc)
we have an entity-type attr on all entities which anchors our expectations as to what other attrs should/may be on the attr
Will the ensure-cf
datomic command work without creating new AWS resources (security groups, roles etc) if existing ones are specified in the input properties files?
how do i use datomic's tempids? what are those -92233... numbers in {-9223301668109598138 17592186045422, -9223301668109598137 17592186045423}
from http://docs.datomic.com/getting-started/transact-data.html ?
@cjhowe those are the IDs assigned to the 3 entities that were created by this transaction
e.g.
{:db/id "movie-1"
:movie/title "The Goonies"
:movie/genre "action/adventure"
:movie/release-year 1985}
the returned tempids should then be something like
{"movie-1" 17592186045422, -9223301668109598137 17592186045423}
@favila taking this opportunity to ask: is there any advantage to using d/tempid
and d/resolve-tempid
over string tempids?
(let [tid1 (d/tempid :db.part/user)
tid2 "string-tempid"
{:keys [tempids db-after]} @(d/transact conn [{:db/id tid1 :db/doc "tid1"}
{:db/id tid2 :db/doc "tid2"}])
tid1-eid (d/resolve-tempid db-after tempids tid1)
tid2-eid (d/resolve-tempid db-after tempids tid2)])
@cjhoweAre partitions something important to think about when developing a small to medium sized app with Datomic? As far as I understand they are “locality hints” and if used properly can increase performance; is that right?
since the partition bits of the entity id are higher, they have a stronger effect on magnitude than the lower bits
(d/entid-at db :db.part/db 1000)
=> 1000
(d/entid-at db :db.part/tx 1000)
=> 13194139534312
(d/entid-at db :db.part/user 1000)
=> 17592186045416
When would the grouping property when sorting by entity ID be desirable? (sorry if the question is silly)
if all items are "close" to one another (same partition), reduces the likelyhood you need to fetch additional blocks or fragment blocks while indexing
e.g. suppose you have two companies using the same db for their data (not that I would recommend this)
read and write patterns are such that txes and queries only deal with one partition at a time if you have companies in separate partitions
@favila so, for example, you might want to store entities and their components in the same partitions?