Search code examples
databasecatalog

What is the most scalable data model for a product catalog?


Each product will have a parent category, a category, and a subcategory.

Would it be better to have a normalized database with integers representing parent category, category and subcategory on the product table?


Solution

  • Its better to have the category table separate and have ids in the product table. else you if you directly store category info in product table you will end up with consistency and duplication.

    you can always join the table while pulling the products, if you are worried of joining you can also cache the categories table in the application side and do a lookup in to the category hash map while picking a product from the table to know about its parent and sub category info.