Here's a database design for the product section in e-commerce, with the condition that a product can have multiple variants and different prices:
Table: Products
ProductID
(Product ID): Primary key, unique integerName
(Product Name): StringDescription
: TextCreatedAt
: Date and timeUpdatedAt
: Date and time
Table: Categories
CategoryID
(Category ID): Primary key, unique integerName
(Category Name): String
Table: ProductVariants
VariantID
(Variant ID): Primary key, unique integerProductID
: Foreign key referencing Products tableName
(Variant Name): String (e.g., Color, Size)Value
(Variant Value): String (e.g., Red, XL)
Table: Prices
PriceID
(Price ID): Primary key, unique integerVariantID
: Foreign key referencing ProductVariants tablePrice
: DecimalCurrency
: String (e.g., USD, VND)
Table: ProductImages
ImageID
(Image ID): Primary key, unique integerProductID
: Foreign key referencing Products tableImageURL
: String
Table: Reviews
ReviewID
Primary key, unique integerProductID
: Foreign key referencing Products tableRating
: Integer (usually from 1 to 5)Comment
: TextCreatedAt
: Date and time
In this design, the ProductVariants
table contains information about different variants of a product, such as color, size. The Prices
table stores price information for each product variant. Each variant can have multiple prices based on different currencies.
Please note that database design can vary based on specific project requirements and how you want to manage products and pricing.