I am in the process of designing a MySQL schema for a website which allows the visitors first to view the list of products (browsing or searching) and view each product in details. Only certain fields are displayed in the listing view and a lot more information is to be displayed when viewing the details, with some fairly big column data (e.g, the product description). The design is quite common. I am wondering what is a good way to store the product information.
One choice is just to have one PRODUCT
table. Viewing the list will have a select a subset of the fields, say, name, price and the main product picture, but not including other fields like description which could be fairly big, say, a VARCHAR(2000). My question is that I do a select name, price, main_pic from product where ...
, will the description fields also get loaded into the memory by MySQL engine, thus consume more spaces?
If MySQL does load other unselected fields into memory or simply just want to keep details in another table, there could be a PRODUCT_DETAIL
table. Would this be a good design? I feel a little weird since both PRODUCT
and PRODUCT_DETAIL
would then have the same primary key, and because of the master-detail relationship between the two, the primary key of the PRODUCT_DETAIL
would also be a foreign key referencing the primary key of PRODUCT
! Anyone actually use this kind of design?