I’ve been thinking lately about how I’ve been approaching data modelling in a way that directly maps to the underlying storage mechanism, e.g. if I use SQL I’ll think in tables and foreign keys, if I use a document store I’ll think in nested documents etc.
However it occurs to me that in many cases this will prematurely lock the entire software design into those limitations, whereas I’d like to keep some kind of flexibility and move the persistence logic down to another abstraction layer.
Especially when starting out thinking about a problem domain, most times I’d want to use plain in-memory data structures that reflect the ideal state of my data, and then serialise those to some frontend for presentation and back-end for storage.
Does Clojure provide any mechanisms that will aid with this approach?
For example, taking the usual “blog” domain with “articles” and “authors”. If two articles have the same author, I’d like to represent that author in memory only once, and that means that I’d use something like a
atom to add one level of indirection. But that will start to complicate things since the usual functions that work with nested maps will stumble.