clojuredesign-podcast

Discussions around the Functional Design in Clojure podcast - https://clojuredesign.club/
JoshLemer 2019-11-12T21:22:53.020Z

Hey folks, wanted to say thanks for the really great podcast, coming from a clojure newbie. Cheers!

neumann 2019-11-12T21:23:44.020100Z

@joshlemer Thanks! I'm glad you're enjoying it and finding it helpful!

JoshLemer 2019-11-12T21:33:42.028100Z

Here’s one thing you could talk a bit about. The podcast and a lot of Clojurists talk about unnesting data so that it is flattened rather than quasi-hierarchical, but that makes me wonder about how do folks handle sequence nestings (aka values which are vectors). For instance, maybe something like:

{
    :user/id 1
    :user/name "josh"
    :user/comments: [
      { :comment/id 1 :comment/text "hi there" }
      { :comment/id 2 :comment/text "hi there again" }
    ]
}
maybe the idiomatic approach is to go fully relational, and flatten to:
{
 {:user/id 1 :user/name "josh" :comment/id 1 :comment/text "hi there" }
 {:user/id 1 :user/name "josh" :comment/id 2 :comment/text "hi there again"}
}
if that’s what you do though, I wonder what you do for cases where there’s two vector fields:
{
    :user/id 1
    :user/name "josh"
    :user/comments: [
      { :comment/id 1 :comment/text "hi there" }
      { :comment/id 2 :comment/text "hi there again" }
    ]
    :user/friends: [ { :user/id 2} { :user/id 3 }]
}
would you then explode again for a total of 4 rows? and if you do flatten like this, I wonder if it gets confusing in your day to day to day programming trying to remember what the “primary key” is, of your flattened structures.