I have an ecommerce store that I am building. I am using Rails/ActiveRecord, but that really isn't necessary to answer this question (however, if you are familiar with those things, please feel free to answer in terms of Rails/AR).
One of the store's requirements is that it needs to represent two types of products:
- Simple products - these are products that just have one option, such as a band's CD. It has a basic price, and quantity.
- Products with variation - these are products that have multiple options, such as a t-shirt that has 3 sizes and 3 colors. Each combination of size and color would have its own price and quantity.
I have done this kind of thing in the past, and done the following:
- Have a products table, which has the main information for the product (title, etc).
- Have a variants table, which holds the price and quantity information for each type of variant. Products have_many Variants.
- For simple products, they would just have one associated Variant.
Are there better ways I could be doing this?