Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Table Inheritance: What's It Good For? (ledgersmbdev.blogspot.com)
3 points by okket on May 26, 2019 | hide | past | favorite | 1 comment


I've just been experimenting and evaluating inheritance for a new project for the past week, and while I felt it could have been a great fit in some cases, I choose not to use it due to the many recommendations to stay clear of it. I finally felt good about my decision a couple of days ago when I saw the "official" recommendation here: https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use...

Now reading this post, I'm curious again :-) One case where I had inheritance in mind was to track row ownership and dates for app users. For instance, I currently have 56 tables which all contains the same columns (owned_by, created_by, deleted_by, created_at, deleted_at). Now as far as I understand, I'd still have to define foreign keys for owned_by, created_by and deleted_by on each table, so I wasn't sure the gain of inheritance was good enough considering potential downsides I wasn't able to evaluate properly without more knowledge / experience. I think my case looks a lot like the notes example, and I wonder if there are any pros/cons in using inheritance for a case like this?




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

Search: