Let's say we're having an application which should be able to store all kind of products. Each product has at least an ID
and a Name
but all other attributes can be defined by the user himself.
- E.g. He could create a productgroup Ipods which would contain attributes capacity and generation
- E.g. He could create a productgroup TShirts with the attributes size and color
- We need to store the definition of a product and the concrete products itself.
- We want to ensure that it is easily possible to aggregate (GROUP BY) by product attributes. E.g. select the total sum of capacity for each generation of ipods
- The solution must not require schema changes (added requirement due to input from Bill Karwin - see his answer as well!)
How would you model your schema in respect to the above requirements?
Note: Requirment 4. is important!
Thanks everyone for contributing and discussing the approach. I have seen some solutions to this problem in the past but none of them made grouping easy for me :(