|
|
|
|
|
by weavejester
2617 days ago
|
|
While Postgres supports hierarchical data in the form of JSON, that doesn't mean it's a form of relational data, it just means Postgres supports both. Clojure doesn't have good tools in its core library for working with relational data. There's no core type that explicitly represents a relation, and Clojure lacks functions for many basic relational algebra operations. For example, how would you perform a natural join across your data structure? |
|
Convert(or design) data to hash-map, join (or merge) by key.
it can write commonly used operations as functions, try to row (or col) operations as much as possible, and join all data only when necessary(reduce the row-join).
```clojure
(def a {:a-id-01 {:a-name "a1"}
(def b {:b-id-01 {:a-id :a-id-01 :b-name "b2"} (->> b ;=>;"a1"
(let [x (b :b-id-01)]
;=>;{:a-id :a-id-01,
; :b-name "b2",
; :a-name "a1"}
```