Hacker News new | ask | show | jobs
by gregplaysguitar 1426 days ago
“Flexibility” isn’t why nosql patterns are useful - at least not in the sense of fewer constraints on your data.

Imagine you’re writing an editing interface of some sort with images, text blocks etc. Each is conceptually a “node” but have different attributes. A single node table with a column per attribute means redundant columns. A table per node type introduces other problems because you need to query all your nodes together. Basically however you model this you end up with tradeoffs and real apps can obviously get much more complex - next thing you have 50 tables and a complex query just to get the data out.

Contrast to the other extreme - storing the whole thing in a single hierarchical json document. There’s no restriction on the data shape, and you can just pass the whole thing around as json. Versioning becomes much simpler because you’re versioning a single document. Your export format is just the json.

There’s tradeoffs of course, and often a middle ground is the right approach - but json columns with validation definitely have their place.