Hacker News new | past | comments | ask | show | jobs | submit login

I recently read a lot about solutions people have come up with to put a class hierarchy into a relational DB, because it all mostly applies when the domain’s data model makes heavy use of ad hoc union union types (like TypeScript’s union types).

If you only skimmed the StackOverflow post or were about to bounce because “my models don’t form complex inheritance hierarchies,” ask whether you’ve tried to serialize something with type `A | B` to the database and been frustrated at there being no good solution. Then (re-)read the post in that framing and see if the solutions proposed and tradeoffs discussed look more relevant to you.

It’s made me realize that there’s probably a lot more collected wisdom locked up in writings from the 90’s and early 00’s that I disregard because it’s so heavily class inheritance focused. Alternatively: free blog post ideas by re-contextualizing this content in contemporary languages and technologies!




I might be biased because I do what you might call "data engineering", but my first thought was "there are three obvious ways to do this", and the accepted answer lists exactly those three ways. You'll find that none of them work very well when you have 100 classes rather than 2, because the "correct" answer is to model your data to be relational in the first place. Yes, sometimes it's unavoidable because the structure of the data is just like that, but more often than not someone somewhere is doing something very wrong.

> realize that there’s probably a lot more collected wisdom locked up in writings from the 90’s and early 00’s

Yes and no, it's the "design patterns" discussion all over again. Some of it was genuinely interesting, but most of it just was incidental complexity caused by early Java and the absolute horror of pre-standard C++. When you filter that out so that only timeless foundational concepts remain, you'll find that most of it had already been said before.


I was also genuinely shocked to see this article make it so far up in HN.


My main wish for postgres for a while has been to support ADT. I know it's probably incompatible with optimizing storage, but it would solve so many problems I have when designing dbs




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: