Wednesday, March 7, 2012

Another database design issue help!

Hello all,
I am developing a web application and im in the middle of database design and facing a design issue. Here it is: A table for products a table for SizeChart (Small, Medium, Large) ColorChart (White, Ash, Yellow, Pink).
Each product is available in combination of different colors and size. Then product has images which are stored based on the selection from ColorChart table. I have created a table where many to many relation between product to color and size are related with primary key identity field for junction table too. I also have created a table tblProdImages with ProductID, ColorID, ImagePath fields
Here is the structure
Product ColorChart SizeChart
--- ---- ----
ProductID ColorID SizeID
Name ColorIcon Sybol

ProductColorSizeChart (junstcion table) ProductImages
------------ ------
ProductColorSizeID (Indentity) ProductImageID (Identity)
ProductID - FK ProductID - FK
ColorID - FK ColorID - FK
SizeID - FK ImagePathThumbnail
InStock ImagePathLarge
Offline

I have write DAL for product and managing junction table relation as collection in my product b/e object.
Here is my question
1- How effective this whole db schema is and how manageable is the relations, Suggest if any better solutions is.
2- Im facing updating problem in ProductDAL for updating collection items in database.
3- How can i manage and implement lazy loading in this scenario in my own written Data Access Layer.

Please clarify 'DAL' and 'b/e'|||1) The schema looks pretty good. The relationships look fairly straight forward and easy to maintain.
2 ) It would help if I had a better idea of what your Object Model & DAL look like.
3) It doesnt look like you have a situation where objects have amassive amount of data associated with them. Im not sureLazyLoading would be worth the trouble. Caching the objects andreturning references might be more useful for you.
|||Thanks Jeffrey for a prompt reply. First of all as far as b/e (business entity objects) are concerned they are blue print parent tables. As for relation btw product, color, size i have created a collection where each item is a structure having two fields for b/e of ColorInfo and SizeInfo (mapper of Color and Size tables). There is a possibility that a product may need to be added where this relation may not be applied as that product has no dependency of color and size so the collection will be empty and in DAL (Data Access Layer) class of product i have this check to determin the count of collection. If empty then Save method for relational entity objects will not be called.
I have implemented DAL code for saving relational object (Product,Color,Size) in product. Is it a right place?|||

asp.dude wrote:

Thanks Jeffrey for a prompt reply. First of allas far as b/e (business entity objects) are concerned theyare blue print parent tables. As for relation btw product, color, sizei have created a collection where each item is a structure havingtwo fields for b/e of ColorInfo and SizeInfo (mapper of Color and Sizetables). There is a possibility that a product may need to be addedwhere this relation may not be applied as that product has nodependency of color and size so the collection will be empty and in DAL(Data Access Layer) class of product i have this check to determin thecount of collection. If empty then Save method for relational entityobjects will not be called.
I have implemented DAL code for saving relational object (Product,Color,Size) in product. Is it a right place?


Thatsounds correct to me. I really couldnt tell you much more without seeing code.

No comments:

Post a Comment