I have products table and product_types table. A product belongsTo a ProductType.
product types such as 'Simple Product', 'Bookable Product', 'Product Bundle' etc
The products table has the usual columns such as name, price, desc etc but i need to store additional data (settings) about a product depending on its product type, but not all products need to store settings. These are not custom fields, in other words the settings are not dynamic, the settings are concrete according to product type and columns need to be created for them. They are also not product variations.
One approach, have a single table for products, with columns for all the 'settings' that might be needed in each different kind of product. You use whichever columns are appropriate to each kind of product, and leave the rest null. with this approach I cant enforce integrity and if there's many product types with many settings the table could get unwieldy.
I was thinking polymorphic, where products table has productable_id and productable_type (which points to their respective settings table), but since not all product types need to store settings this isn't viable. I wouldn't need to store settings for a Simple Product, but I would for a Bookable product as I need user to enter data such as Capacity, when creating a Bookable Product.
does anyone have a good solution?