I was trying out Datascript on a personal project, and I ended up with an initial schema like
(def schema {:player/name {:db/index true}
:game/t1 {:db/index true}
:game/t2 {:db/index true}
:game/p1 {:db/valueType :db.type/ref}
:game/p2 {:db/valueType :db.type/ref}
:game/p1-points {}
:game/p2-points {}
:game/time {}})
I'm quite surprised that the ref types don't actually reference anything explicitly in Datascript
but just says it's a ref, I guess that's normal, but it means you can't easily generate a graph of all the schema and the various relationships?
What would the ref types reference, exactly? In DataScript the reference can point to any other entity in the DB. You could generate a graph of various relationships once you populate it with data (e.g. “show me all the ‘kinds’ of entities that are referenced by :game/p1
“, but how you define ‘kinds’ is specific to your domain).
You can just add your own metadata to the schema.
Yeah I mean it's weird that you only what something references to when you populate with data
Datascript / Datomic are inherently polymorphic, which can feel a bit weird if you're used to thinking about SQL relations between tables. But if you've ever had to do polymorphism in SQL (LSS: it sucks), the relative freedom in DS is marvelous. You can still add entities to the db if you like that represent each of your reference types (in DS I mean; In Datomic, you create schema by creating entities already), and add entity types for different kinds of entities. But this is sort of a build it yourself endeavor. Which is also kind of freeing in a way, because you can do it just the way you want it, instead of being boxed into the specifics of a SQL/table relational model.
Yeah I got it now and it's quite cool