Database Design For Multiple Product Types

  • I have a database containing different product types. Each type contains field that differs greatly with each other. The first type of product, is classified in three categories. The second type of product, is classified in three categories. But the third and the fourth one, is not classified in anything.

    Each product can have any number of different properties.

    I have a huge database,which containing about 500000 product in product table.

    So when I am going to fetch a product from database with all its attributes, or going to search product filtering by attributes, it makes effect on performance badly.

    Could any one can help me what will be the tables structure in sql . Because different ecommerce sites are using this kind of database and working fine with huge different types of products.

  • sahaamitabha123 (6/15/2013)


    I have a database containing different product types. Each type contains field that differs greatly with each other. The first type of product, is classified in three categories. The second type of product, is classified in three categories. But the third and the fourth one, is not classified in anything.

    Each product can have any number of different properties.

    I have a huge database,which containing about 500000 product in product table.

    So when I am going to fetch a product from database with all its attributes, or going to search product filtering by attributes, it makes effect on performance badly.

    Could any one can help me what will be the tables structure in sql . Because different ecommerce sites are using this kind of database and working fine with huge different types of products.

    Two basic tables, tbl-products and tbl-products-attributes

    >> basic columns for tbl-products

    product_code PK,

    category,

    blah... blah... blah...

    >> basic columns for tbl-products-attributes

    product_code FK pointing to tbl-products(product_code)

    product_attribute_code

    blah... blah... blah...

    Please make sure of making tbl-products-attributes PK as (product_code,product-attribute_code)

    In regards to the 'category' issue, fake it! for third and fourth types of products make all of them belong to category = "ALL"

    By the way, when asked about the reasons why you choose to define the "ALL" category, do not say "I faked the category", you can phrase it like: "products types 3 and 4 can be considered as having an implicit category to which all belong - this choice allows to model all products the same way bringing more flexibility to the overall design" 😉

    Hope this helps.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply