Columnar Storage Is Normalization

(buttondown.com)

41 points | by ibobev 3 hours ago ago

19 comments

  • immanuwell 2 hours ago

    The normalization analogy is genuinely clever as a teaching tool, but it quietly papers over the fact that normalization is a logical design concept while columnar storage is a physical one - treating them as the same thing can mislead more than it clarifies, I think

    • jerf 2 hours ago

      I've always preferred to think of normalization as more about "removing redundancy" than in the frame it is normally presented. Or, to put it another way, rather than "normalizing" which has as a benefit "removing redundancy", raise the removing of redundancy up to the primary goal which has as a side benefit "normalization".

      A nice thing about that point of view is that it fits with your point; redundancy is redundancy whether you look at it with a column-based view or a row-based view.

    • hilariously 2 hours ago

      Fair, but one of the big benefits of normalization was the benefit on storage and memory back in the day which was tiny comparatively.

      There's always a reason for a dev to ship something shitty but when you show you can use 80% less storage for the same operation you can make the accountants your lever.

      • bazoom42 35 minutes ago

        The purpose of normalization is not to save storage. In fact it might often require more storage, since it involves introducing a foreign-key column. It really depends on the data in question whether it saves storage or require more.

        • hilariously 9 minutes ago

          Fair, I said one of the big benefits, not the purpose - in some cases it can require more storage (but that storage is often more amenable to compression) -but generally deduplicating your data doesn't increase your storage needs.

      • jklowden 2 hours ago

        Nonsense. See Codd’s first paper.

        1NF removes repeating groups, putting for example data for each month in its own row, not an array of 12 months in 1 row.

        Storage efficiency was never the point. IMS had that locked down. Succinctness of expression and accuracy of results was the point. And is: normalization prevents anomalous results.

        • HelloNurse an hour ago

          Normalizing repeating groups doesn't offer significant savings when they are completely populated (e.g. each entity has the full 12 monthly values per year), but other types of normalization do. For example dependent data are actually redundant.

        • sgarland an hour ago

          I think parent was saying it’s a benefit, not the original purpose. If I store a FK to a table containing my company’s corporate address, that is a tremendous savings in storage (and memory pressure), and it also eliminates update anomalies.

  • remywang an hour ago

    This is exactly domain key normal form!

    https://en.wikipedia.org/wiki/Domain-key_normal_form

    • bazoom42 5 minutes ago

      Not exactly. It is 6th normal form.

  • parpfish 2 hours ago

    I always thought that the biggest benefit of normalization was deduplicating mutable values so you only need to update values in one place and everything stays nicely in sync.

    Classic example being something like a “users” table that tracks account id, display name (mutable), and profile picture (mutable). And then a “posts” table that has post id, account id, and message text. This allows you to change the display name/picture in one place and it can be used across all posts

    • sgarland an hour ago

      That is a practical benefit, absolutely. A different way of looking at it is that you’re eliminating data anomalies (generally, update anomalies).

    • bazoom42 an hour ago

      This is usually the case when talking about normalization in the contex of relational databases (2nd normal form, 3rd normal form etc.). But normalization really just means to bring data into some standardized form.

  • juancn an hour ago

    It is possible to treat as purely relational but it can be suboptimal on data access if you follow through with it.

    The main cost is on the join when you need to access several columns, it's flexible but expensive.

    To take full advantage of columnar, you have to have that join usually implicitly made through data alignment to avoid joining.

    For example, segment the tables in chunks of up to N records, and keep all related contiguous columns of that chunk so they can be independently accessed:

        r0, r1 ... rm; f0, f0 ... f0; f1, f1 ... f1; fn, fn ... fn
    
    That balances pointer chasing and joining, you can avoid the IO by only loading needed columns from the segment, and skip the join because the data is trivially aligned.
  • data-ottawa 36 minutes ago

    The Apache Arrow array format docs are a great read if you're interested by this blog post.

  • Lucasoato 2 hours ago

    This is an interesting thought, even if it doesn’t come with practical consequences. A person could argue that if you happen to encode your table with a columnar format, you very likely won’t use indexes for every “value” but the order itself of that specific block. But this would mean that if you’re using the data order meaningfully, you’d probably going against the principles of table normalization. But, again, this one as well can be considered the result of excessive overthinking rather something practical that can be used.

  • pwndByDeath 2 hours ago

    None-or-many?

  • orangepanda 2 hours ago

    Is this meant to be a poor explanation of sixth normal form?

    • sgarland an hour ago

      THANK YOU. I was confused at the normalization example given, and had to think through it. (id, name, age) is already at 5NF, and the only one it doesn’t satisfy is 6NF.