I am currently creating an auction site, where it should be possible to create an auction of one or more products. This should be managed with some different variations of products.
My problem is, that I’m not sure if I have build the best MySQL structure for handling the stock management. Here is how my DB looks:
Attributes
AttributeValues
Combinations
CombinationParts
Here I will have the following connections:
Attributes is the "main" name of the attribute - e.g. "Size", "Colour" or so. This has a
ProductID (connecting it to a product).
AttributeValues is the value - e.g. "43", "44", "45"...
I connect this to Attributes on a field called AttributeID.
Then I will create some combinations – e.g. if a shoe has more attributes a Combination will be made.
Combinations has the name and stock of the product - connected
to a product on ProductID
- e.g. "Nike shoe, red, 43" or "T-shirt, blue, Large".
CombinationParts is then connecting to a product with an AuctionID and then
to a AttributeValue with AttributeValueID.
EDIT: The reason I connect the stock to each product is, that I need to make it possible to connect more products to an auction
The idea is, that when you create an auction you type in how many of each type, there is in stock.
My problem is wheter I could make the same easier? In other words: Is this optimal when I need to scale my site to maybe containing 25,000 products?
Having a key-key-value table (product X, “brand”, “nike”) is a good way of dealing with attributes and values when the set of possible attributes is unknown. It can be clumsy when querying sometimes, but it’s much easier to maintain.