我在做一个电子商务项目,并感到困惑的数据库设计用于存储产品。有3种方式,我推测该数据库可制成:设计一个电子商务数据库 - MySQL的
1. 每个产品类别可以有不同的表。
Table: Categories
------------------
cat_ID
cat_name
Table: Sub_Categories
---------------------
sub_cat_ID
categories_cat_ID
sub_cat_name
Table: Books
-------------
book_ID
sub_categories_sub_cat_ID
book_title
book_author
book_ISBN
book_price
etc
Table: Clothes
---------------
clothes_ID
sub_categories_sub_cat_ID
clothes_name
clothes_color
clothes_size
clothes_description
clothes_price
etc
Table: Perfumes
----------------
perfumes_ID
sub_categories_sub_cat_ID
perfume_name
perfume_size
perfume_weight
perfume_description
perfume_price
etc
2. 组中的所有产品一起在一个表中,并且允许一些值为空
Table: Categories
------------------
cat_ID
cat_name
Table: Sub_Categories
---------------------
sub_cat_ID
categories_cat_ID
sub_cat_name
Table: Products
---------------
product_ID
sub_categories_sub_cat_ID
title
description
price
author (can be null for everything except books)
size
weight (can be null for everything except perfumes)
ISBN (can be null for everything except books)
color (can be null for everything except clothes)
etc
3. 组类似列字段一起在表中称为产品,并提供为单独的表具体数据。
Table: Categories
------------------
cat_ID
cat_name
Table: Sub_Categories
---------------------
sub_cat_ID
categories_cat_ID
sub_cat_name
Table: Products
----------------
product_ID
sub_categories_sub_cat_ID
title
description
price
Table: Books
-------------
products_product_id
sub_categories_sub_cat_ID
author
publisher
ISBN
Table: Perfumes
----------------
products_product_id
sub_categories_sub_cat_ID
size
weight
Table: Clothes
--------------
products_product_id
sub_categories_sub_cat_ID
color
size (this can be a one to many relationship to cater to multiple sizes of one product?)
我会很感激的启示,谢谢
谢谢你的帮助。我的主要问题是如何/在哪里为不同类型的产品存储不同的数据。即您是否会在产品表中为作者/ ISBN /颜色/尺寸/重量/等等添加一列,或者将它们分开以避免使用空值? – a7omiton
我想有一个基地'products'表,然后也许像ISBN号的其他数据的'product_attributes'表,而不是每个产品都将有一个ISBN号码,如果它不是一个发布。 –
所以方法3将是要走的路(除了sub_categories表)?还是你说所有产品的每个属性都应该放在表product_attributes中? – a7omiton