a) simpler
For your information, with postgresql you have table inheritance https://www.postgresql.org/docs/9.1/tutorial-inheritance.html
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have 3 tables, book, film and music. I want to present this data individually, as in a list of books and as a feed of all three types.
I cannot decide which route to take to implement the feed...
a) Create a MySQL view, based on a union of the three tables above. I'd then read this and it would automatically update when the underlying tables update. The view would have some null columns as the 3 underlying tables do not have completely the same set of fields.
OR
b) Create a feed table with a one to one polymorphic relationship to either book, film and music. When I add a row to one of the underlying tables, I must create the reference on the parent feed table.
It's also worth noting that with either option when loading, I would still need to access the underlying book, film or music table as I would want to get all feed items (book, film or music) and eager load additional relationships defined on the book, film or music tables, for example, comments.
Any advice is appreciated.
Please or to participate in this conversation.