I am creating a web application where the product can have several different types (types of furniture, actually) and depending on these types, the product has certain fields associated with it.
Fast background . I use MySQL and PHP with CakePHP as my framework. The answer I'm looking for does not have to be "CakePHP-like"; I would prefer that the first MySQL is best suited for database design, and formost.
So, I can present two options:
Single table variant - I have one products table with all possible fields and just leave fields that are not used for this particular product as null . This, I think, is the simplest design, but integration will require a few shoes for shoes (since my model will need to track the type and which fields should actually be updated based on this type.)
Table options for multiple products . - Each product receives its own table with the appropriate fields for a particular type of product. There is a master table ( products ) that contains at least three fields id (primary key), productType (for finding the right table) and productTypeId (which connects the product table to a specific product table.
I am very inclined to # 1, but would like to get other people's thoughts.
Let me know if you need more details! Thanks!
Update: I would expect only a small set of types of furniture (<10 to start, the maximum would ever be 20).
source share