News for hackers. Stuff that matters.
Re:Rob Pike's 5 Rules of Programming by mosura on Wednesday March 18, 2026 @09:42AM (#47425720)
Often significant improvements to every aspect of a system that interacts with a database can be made by proper design of the primary keys, instead of the generic id way too many people jump to.

The key difficulty is identifying what these are is far from obvious upfront, and so often an index appears adjacent to a table that represents what the table should have been in the first place.

Re:Rob Pike's 5 Rules of Programming by embedding-shape on Wednesday March 18, 2026 @09:57AM (#47425888)
I guess that might be true also, to some extent. I guess most of the times I've seen something "messy" in software design, it's almost always about domain code being made overly complicated compared to what it has to do, and almost never about "how does this domain data gets written/read to/from a database", although it's very common. Although of course storage/persistence isn't non-essential, just less common problem than the typical design/architecture spaghetti I encounter.
Re:Rob Pike's 5 Rules of Programming by Pxtl on Wednesday March 18, 2026 @10:25AM (#47426198)
I'm a firm believer in always using an auto-generated surrogate key for the PK because domain PKs always eventually become a pain point. The problem is that doing so does real damage to the ergonomics of the DB.

This is why I fundamentally find SQL too conservative and outdated. There are obvious patterns for cross-cutting concerns that would mitigate things like this but enterprise SQL products like Oracle and MS are awful at providing ways to do these reusable cross-cutting concerns consistently.