Quantcast
Viewing latest article 5
Browse Latest Browse All 6

Answer by Chris Cudmore for Designing an 'Order' schema in which there are disparate product definition tables

This might get you started. It will need some refinement

Table Product ( id PK, name, price, units_per_package)Table Product_Attribs (id FK ref Product, AttribName, AttribValue)

Which would allow you to attach a list of attributes to the products. -- This is essentially your option 3

If you know a max number of attributes, You could go

Table Product (id PK, name, price, units_per_package, attrName_1, attrValue_1 ...)

Which would of course de-normalize the database, but make queries easier.

I prefer the first option because

  1. It supports an arbitrary number of attributes.
  2. Attribute names can be stored in another table, and referential integrity enforced so that those damn Canadians don't stick a "colour" in there and break reporting.

Viewing latest article 5
Browse Latest Browse All 6

Trending Articles