开发者

Database Design: Why do some ecommerce database have separate tables for products and product_variants?

Why do some ecommerce database have tables:

  1. product
  2. product_variant

Why not only one product table w开发者_开发技巧ith all teh fields of product_variant and is_default_product(bool) field?

Thanks


This is called Slowly Changing Dimension

There are some approaches to implementing it which have their benefits and drawbacks.

Solution with two tables allows easier referencing to products (as opposed to product versions) from other tables.


If you have only one table, you have to modify your database design if you want to add product attributes. So if you are tracking colors and sizes in your table, and you want to add, say, inseam, you have to add a column to the table.

Keeping a separate table of attributes allows you to easily manage your attributes as entries in the table, rather than have them be a part of the actual design.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜