ASP.NET - Relating products - Asked By asif hameed on 13-Jan-10 01:05 AM

Hi all,

I am creating an asp.net website. I have products page. When user will click any product, a detail page will open with large product view. Behind this will be a row showing related products.and on top there is a row which shows same product in other colors. there is another row showing colors available for that product. User can click any color and its thumbnail will be show big. I need to know table structure. I guess there will be three tables

Products

Colors

product colors table ( junction table)

but where will i save images for product and related products and how they will relate to current product.

Please help me on this.

Regards,

Asif Hameed


Re - Huggy Bear replied to asif hameed on 13-Jan-10 01:22 AM

There are two options for you:

1. Store the image also against the product itself as a BLOB data. BLOB is nothing but a representation of byte[] and the abbreviation is Binary Large Object and the filename for it, if necessary.
2. Second option would be to store the images on the file system and their filenames in the database against the product. When you what to show the image read the file name from the table and get the corresponding file from the file system. You should be storing the directory path of the stored files in the configuration file.

If I was you, I would opt for having the image in the file system only and not in the database. I am not a big fan of storing the BLOB data in the table.

Relating products - asif hameed replied to Huggy Bear on 13-Jan-10 01:32 AM

Hi Huggy:

Thanks for the response and suggestion. Actually, I am looking for suggestions on relating prodcuts. How different colors products will be related and what will be table structure.

Regards,

Asif Hameed

DB design: Related Products - mv ark replied to asif hameed on 14-Jan-10 01:10 AM

Instead of 2 tables Colors & ProductColors, you can consider having a single table called, more generically, ProductVariations that can have a structure like this -
VariationId int PK
ProductId int
Description varchar - optional column that can hold the color or any other description
ImagePath varchar - file path of product image in distinct color

You can have a seperate table called RelatedProducts with similar structure

To fetch variations & related Products, join respective tables