Bug / Omission? Lack of Unique Constraints in Database

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Bug / Omission? Lack of Unique Constraints in Database

Post by ZLA » Wed Jul 29, 2009 9:08 am

I was getting the following error on my product display page: [[ConLib:Custom/SG_BuyProductDialog]] Item has already been added. Key in dictionary: 'Name' Key being added: 'Name'. It turns out I had added duplicate entries in ac_ProductTemplateFields when I was running a SQL script to update some product templates. For example, I found the following two records in ac_ProductTemplateFields:
  • ProductTemplateFieldId, ProductId, InputFieldId, InputValue
  • 216, 129, 154, sg
  • 305, 129, 154, sg
I'm pretty sure this can't happen via the Admin interface but I was surprised that the table didn't have a unique constraint on it to prevent this from happening. I looked further and found that other than primary keys, the only tables with additional indexes are ac_CatalogNodes, ac_OrderItems, ac_PageViews and ac_Products.

For performance reasons, I could understand not having additional unique constraints on basket or order tables but a table like ac_producttemplatefields is really only used by admin and shouldn't cause any performance hit (other than database size). There are probably other tables that could have unique constraints applied.
  • Am I correct that ac_ProductTemplateFields should not have duplicate entries as described above?
  • Are there reasons why unique constraints should not be applied to various tables in the system?
Thanks.

Post Reply