Skip to content

Comment on Inventory management in MongoDB: A design philosophy I find bafflingparent

Comments

Transactions are never needed with a fully normalized model so if transactions are needed it is probably because your model sucks.

Or it is because you denormalized your model because your db engine's performance sucks in which case the transactions will probably just make it worse.

Good schema design and lock-free/wait-free (transaction-free) algorithms are not "reimplementing transactions in the client."

OPs example is garbage but his proposed transaction solution is garbage too.

Eh? If you don't have transactions of some sort you can't update multiple tables simultaneously, which you need for a denormalised model?

If your schema is fully normalized then you never have two instances of the same data in more than one place therefore you never have to update two things simultaneously.

Anytime you need a transaction it is because you have the same data, or some calculated derivative of the same data, stored in different places, which is why they both have to be updated at the same time to maintain consistency.

"Transactions are never needed with a fully normalized model": I just don't agree. Fully normalized most likely means many tables for everything, and transactions are needed to maintain consistency.

"you denormalized your model because your db engine's performance sucks": you're most likely to denormalize because joins are costly no matter what DB you're using.

"the transactions will probably just make it worse": denormalization is most often used to reduce the number of operations (so transactions are unlikely to make things worse).

I agree about the amount of garbage in the article though.

Odd, never thought of the distributed implementations as normalized or not, though that's exactly what the underlying design is about. Thanks! You must design at a minimum a normalized way to store data reference keys, but the prevalence of SQL makes me implicitly associate 'normalization' only with SQL. It's also good to note that adding in vector clocks / revision keys lets you store denormalized data (e.g. Caching with staleness detection) in various data stores as long as the parent id and revision keys are normalized somewhere.

Re: pjc50, yes that's what calafrax means.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.