I have to design database for cloth and shoes ecommerce website,
I'm not sure I did proper or not for future postgresql querying usage?
Example The product could be like:
(name) a shoes > (size) 36 > (color) red > (price) 100 > (qty) 2
(name) a shoes > (size) 37 > (color) red > (price) 300 > (qty) 4
(name) a shoes > (size) 38 > (color) red > (price) 500 > (qty) 4
(name) b shoes > (size) 36 > (color) green > (price) 200 > (qty) 6
...
(name) a top > (size) xs > (color) purple > (price) 300 > (qty) 2
...
(name) a pants > (size) 100-120cm > (color) pink > (price) 100 > (qty) 2
...
(name) b pants > (size) s > (color) pink > (price) 100 > (qty) 2
The size not always sml or n-n cm... could be any the string from the item manufacturer so I leave column as input some text.
and I separate color (product_size_color
) price (product_size_color_price
) and quantity (product_size_color_price_quantity
) because the website is multiple language so in future I have to creat another table like product_size_color_jp
, product_size_color_price_jp
...
please any suggestion are welcome..
table: product_base
primary:
product_id
column:
product_id SERIAL NOT NULL,
product_name varchar,
product_introduction varchar,
product_description varchar,
active bit NOT NULL,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
table: product_size
primary:
product_size_id
column:
product_size_id SERIAL NOT NULL,
product_id integer NOT NULL, FOREIGN KEY (product_id) REFERENCES product_base (product_id) ON DELETE CASCADE
product_size_name varchar,
product_size_description varchar,
active bit NOT NULL,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
table: product_size_color
primary:
product_size_color_id
column:
product_size_color_id SERIAL NOT NULL,
product_size_id integer NOT NULL, FOREIGN KEY (product_size_id) REFERENCES product_size (product_size_id) ON DELETE CASCADE
product_size_color_rgb_code_r integer,
product_size_color_rgb_code_g integer,
product_size_color_rgb_code_b integer,
product_size_color_name varchar,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
table: product_size_color_price
primary:
product_size_color_price_id
column:
product_size_color_price_id SERIAL NOT NULL,
product_size_color_id integer NOT NULL, FOREIGN KEY (product_size_color_id) REFERENCES product_size_color (product_size_color_id) ON DELETE CASCADE
product_size_color_price integer,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
table: product_size_color_price_quantity
primary:
product_size_color_price_quantity_id
column:
product_size_color_price_quantity_id SERIAL NOT NULL,
product_size_color_price_id integer NOT NULL, FOREIGN KEY (product_size_color_price_id) REFERENCES product_size_color_price (product_size_color_price_id) ON DELETE CASCADE
product_size_color_price_quantity integer,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
UPDATE
table:
product_base
primary:
product_id
column:
product_id SERIAL NOT NULL,
name varchar,
introduction varchar,
description varchar,
size_name varchar,
size_description varchar,
active bit NOT NULL,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
table:
product_color
primary:
product_color_id
column:
product_color_id SERIAL NOT NULL,
product_id integer NOT NULL, FOREIGN KEY (product_id) REFERENCES product_base (product_id) ON DELETE CASCADE
color_rgb_code_r integer,
color_rgb_code_g integer,
color_rgb_code_b integer,
color_name varchar,
active bit NOT NULL,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
table:
product_color_price
primary:
product_color_price_id
column:
product_color_price_id SERIAL NOT NULL,
product_color_id integer NOT NULL, FOREIGN KEY (product_color_id) REFERENCES product_color (product_color_id) ON DELETE CASCADE
price integer,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
table:
product_color_quantity
primary:
product_color_quantity_id
column:
product_color_quantity_id SERIAL NOT NULL,
product_color_id integer NOT NULL, FOREIGN KEY (product_color_id) REFERENCES product_color (product_color_id) ON DELETE CASCADE
quantity integer,
create_by_user_id integer,
create_date timestamp,
modified_by_user_id integer,
modified_date timestamp
(product_id, language)
. All translations for diff. languages are in the same table. Partial indexes can be used for language-aware fulltext search. – Craig Ringer