In our e-commerce application, we have different kinds of products having different kinds of attributes, e.g., a shoe has different selling features than an edible cake. Our e-commerce site allows you to "build" your own products, selecting various attributes and values (like pink frosting on a cup cake which adds $.25 to the cost).
Our first construction looked something like this. This is a NIGHTMARE to maintain. I am looking for suggestions on how to assemble these tables (or objects) in a more normalized and realistic way.
We have a pretty standard product table with more fields than this but you get the idea:
public class Product {
public int id {get;set;}
public string name {get;set;}
public decimal price {get;set;}
}
We have an options table that lists all the options that can be selected for a given option group (think of a single Drop Down List):
public class Options {
public int oId {get;set;}
public string oName {get;set;}
public decimal oPrice {get;set;} // Added to base price if selected
}
Then we have a many-to-many table tying both of these together, where the presence of a record ties an option to that product:
public class ProductOptions {
public int id {get;set;}
public string oId {get;set;}
}
We are trying to assign similar options to similar products, like all Cakes generally have the same flavors, all icing generally has the same colors, etc. so that when we change options, it changes for all related products.
Any suggestions will be most appreciated, especially in a DDD way.