0% found this document useful (0 votes)
48 views8 pages

DB Design Ecommerce Products

Uploaded by

triggered1090
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views8 pages

DB Design Ecommerce Products

Uploaded by

triggered1090
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Database Design:

eCommerce Products

A guide for a database design for the products within


an eCommerce website

Ben Brumm
www.databasestar.com
Database Design: eCommerce
Products
This guide is a companion to my YouTube video on designing the product area of an eCommerce
website. The video used the website asos.com as an example, but the design should work for other
eCommerce solutions.

In this guide, you'll see:

● An Entity Relationship Diagram for the product area of an eCommerce website, from my
YouTube video.
● An explanation of the purpose of each table and field, with sample data.
● SQL scripts to create each of these tables with some sample data.

Let's get into it.

Entity Relationship Diagram


Here's the ERD for this database:

A PNG file of this ERD is available here:

https://dbshostedfiles.s3.us-west-2.amazonaws.com/dbs/erd_ecommerce_products.png
Guide Title

SQL Scripts
The SQL Script to create this database, and populate some sample data, is available on GitHub here:

https://github.com/bbrumm/databasestar/tree/main/videos/127_ecommerce

The script has been written for MySQL, but with some minor tweaks (such as data types), it should
work for all other databases.

Database Definition
This section explains each of these tables and fields.

product_image

A record for each image that exists for a product.

Column Description Sample Data

image_id Primary key. A unique identifier for the 1, 2, 3


row.

product_item_id A foreign key that refers to the ID in the 4, 2, 12


product_item table for the related
product_item

image_filename The location on the server where the /images/product1092_32.png


filename is stored and the name of the file

colour

A lookup table for all of the possible colours for a product.

Column Description Sample Data

colour_id Primary key. A unique identifier for the 1, 2, 3


row.

colour_name The name of the colour, which is shown on Black, Blue, White
the web page.

www.DatabaseStar.com 2
Guide Title

product_category

A record for each of the product categories. This table contains a self-join, so it contains many levels of
categories and subcategories.

Column Description Sample Data

product_category_id Primary key. A unique identifier for the 1, 2, 3


row.

category_name The name of the category, which is Coats and Jackets


short and is shown on the website Shoes
Gym

category_image The location and filename of the image /images/category05.png


for the category

category_description A description for the category which is Check out our collection of
shown on the web page shoes from a range of brands,
and find….

size_category_id The size category that applies to this 21, 4, 10


category (because different categories
have different size options: shoes are
different to clothes)

parent_category_id The product_category_id of this 3, 5, 1


record's parent, if it exists

product

A record for each product, which is shown on the product listing page.

Column Description Sample Data

product_id Primary key. A unique identifier for the 1, 2, 3


row.

product_category_id A foreign key for the product category 2, 5, 9


for this proudct

brand_id A foreign key to the brand table, which 3, 4, 8


represents the brand of this product

product_name The name of this product, shown on the Black Leather Jacket

www.DatabaseStar.com 3
Guide Title

product listing page and the product Nike Air Force Shoes
page. Long Black Dress

product_description A description of the product to provide This jacket is part of our new
more information collection and is designed…

model_height The height of the model in the photos 6ft 1in

model_wearing The size that the model is wearing Medium

care_instructions Any instructions on how to wash, dry, or Mashine wash, cold only
care for the product

about Some information about the product Made with 100% cotton

product_item

A record for a product that comes in a different colour and has a different price.

Column Description Sample Data

product_item_id Primary key. A unique identifier for the 1, 2, 3


row.

product_id A foreign key to the product table for the 3, 5, 12


related product.

colour_id A foreign key to the colour table for the 1, 43, 9


related product.

original_price The price of a product, or its original price 10, 150, 210
if it is on sale

sale_price The price of a product if it is on sale 9, 120, 190

product_code A unique code for the product, which can CAB109874


be used for searching or identifying the
product

brand

A lookup table for the brands of products

Column Description Sample Data

brand_id Primary key. A unique identifier for the 1, 2, 3

www.DatabaseStar.com 4
Guide Title

row.

brand_name The name of the brand that creates a Nike, Adidas, Gucci
product

brand_description A description of the brand to explain more Founded in 1976, the company
about it. specialises in quality…

product_variation

A record for a product item that comes in a specific size. It is represented by a quantity in stock and
this is what is ordered by customers.

Column Description Sample Data

variation_id Primary key. A unique identifier for the 1, 2, 3


row.

product_item_id A foreign key for the related product_item 2, 6, 10

size_id A foreign key for the related size 3, 5, 23

qty_in_stock The number of items that are in stock for 0, 12, 85


this product variation

size_category

A record that represents a category of sizes, such as "Shoes" and "Women's Pants", so the website can
show the correct size options for a category.

Column Description Sample Data

category_id Primary key. A unique identifier for the 1, 2, 3


row.

category_name A description of the category of sizes. Shoes


Women's Dresses
Men's Pants

size_option

A record for the available sizes within a category.

www.DatabaseStar.com 5
Guide Title

Column Description Sample Data

size_id Primary key. A unique identifier for the 1, 2, 3


row.

size_name The name of the size, which is shown on M, 8, 41


the page or in drop-down lists.

sort_order The order to display the sizes in, because 1, 2, 8


sorting them alphabetically is not always
desirable.

size_category_id The category that this size belongs to. 1, 2, 5

product_attribute

A combination of products and the attributes that apply to them, which is used for filtering.

Column Description Sample Data

product_id A foreign key that refers to the product 1, 8, 15


table.

attribute_option_id A foreign key that refers to the attribute 3, 8, 12


option.

attribute_option

A record for all of the available options for different attributes of a product.

Column Description Sample Data

attribute_option_id Primary key. A unique identifier for 1, 2, 3


the row.

attribute_type_id A foreign key that represents the 3, 8, 10


attribute type.

attribute_option_name The name of the attribute option Crew Neck


that can be displayed. Main Collection
Plus Size

www.DatabaseStar.com 6
Guide Title

attribute_type

A record for the different types of attributes.

Column Description Sample Data

attribute_type_id Primary key. A unique identifier for the 1, 2, 3


row.

attribute_name The name of the attribute type, which is Length


the name of the filters shown on the Body Fit
product listing page. Neckline

Conclusion
Hopefully you found this guide, diagram, and script useful.

If you have any questions or suggestions, let me know at [email protected].

Thanks!

Ben Brumm

www.DatabaseStar.com

www.DatabaseStar.com 7

You might also like