There are 5 semi-related tables here, with there related Keys:
Product
[ID]Option
[ProductID]Option_OptionGroupValue
[Option.ID] [OptionGroupValue.ID]OptionGroupValue
[OptionGroup.ID]OptionGroup
What happens is a product can be assigned a number of rows in the 'Option' table.
That Option
table is related to the OptionGroupValue
through the Option_OptionGroupValue
table, which creates a combination of OptionGroupValue
's in the Option_OptionGroupValue
table.
In the application, there are mupltiple fields like this:
<input type="hidden" name="productid" "[ID]">
<select name="optiongroup_<%=OptionGroup.ID%>">
<option value="<%=OptionGroupValue.ID%>"> <%=OptionGroupValue.Name%> </option>
</select>
The rule is that there can only be one unique combination of all these OptionGroupValue
's within each Product
+ Option
.
For Example in the web application:
Product: [ProductID 100]
New Options [Option] Table:
Color [OptionGroupID 100] : Black [OptionGroupValueID 100]
Size [OptionGroupID 101]: Small [OptionGroupValueID 105]
Width [OptionGroupID 102]: Large [OptionGroupValueID 108]
When submitted, it needs to see if that combination exists or not.
I've tried looping through for each Option
inside the app with-in a product, to toggle a bIsUniqueOption = True/False
based on If each (ProductID, OptionGroupID, OptionGroupValueID) Exists
scenario, but unfortunately it doesn't seem to think it's not unique.
I'm not really looking for code, but more of a general approach to something like this if anyone out there has encountered something similar. If someone can jump in a chat, it would really be appreciated. I'm starting to lose it just thinking about.. =/