I’m working on a content management system that needs to handle different types of page layouts without creating tons of database tables. My main problem is that most websites have pages that look similar but contain different fields.
For example, some pages might need a title and text, others need title, image, and gallery, and some might need completely different combinations of fields.
Right now I’m thinking about using two main tables:
table layout_definitions
page_id int
field_structure -- not sure what format to use here
table page_content
page_id int
layout_reference -- links to layout_definitions
actual_data -- stored content, format unknown
My goal is to avoid having separate tables for every content type, but also avoid having tables with dozens of columns for every possible field combination.
I’m considering storing the structure info and actual content as JSON or serialized data, but I’m worried this might be inefficient or hard to query later.
Has anyone built something similar? What are the performance implications of storing structured data this way versus traditional normalized tables? Is this approach maintainable in the long run?