DEV Community

Discussion on: eCommerce Database Design

Collapse
 
jdgamble555 profile image
Jonathan Gamble

Interesting. Could you expound on this? Would like to see benefits...

Thread Thread
 
ezzdinatef profile image
Ezzdin Atef

Yes! In certain instances, I chosen to simplify the categories table by storing only the id and name of the category. Meanwhile, the sub_categories table includes additional details such as id, name, parent_id, description, icon, and a flag to signal anything new or updated in the UI. Additionally, I introduced a group_id for cases where subcategories are logically grouped under a common title.

In other scenarios, I have followed your recommended approach, especially when a client requested categories and subcategories with unlimited depth. Your approach proved to be the most suitable for handling such cases of dynamic hierarchy.