Fork me on GitHub
#clojuredesign-podcast
<
2019-11-12
>
JoshLemer21:11:53

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

neumann21:11:44

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

JoshLemer21:11:42

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.