Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bufferoverflow's avatar

Multiple MySQL tables or one table with everything stored as array in text column

Hi there,

I'm building a page builder. In this page builder, a Page.php can have many PageSections. Each of these page sections has it's own fields like title, subtitle, featured image, video, etc.

I have two choices here:

  1. Polymorph relationship ($page->pageSections->first()->sectionable). Each section is a model, so we need a table in the database. We can add the title and everything in its own database column, add relationships like images with Spatie Medialibrary, easier search, etc.

  2. Store information as an array in PageSection and use Data Transfer Object to read and write information.

I haven't been in this situation before, so I'm not sure if the complexity of maintaining a model/table for each page section is worth the benefits. Or a simple text column in the page section would work just fine.

Any tips from someone who has been in this situation? Am I missing something?

Thanks!

0 likes
2 replies
vincent15000's avatar

My opinion is that it's often better to user multiple tables than an array in a text column. But it depends on your needs : if you don't do any search, any ordering, ... on the data, you can simply store them in an array. If you need to do some search, ordering, ... it's much better to store them in another table.

Please or to participate in this conversation.