Wednesday, 21 August 2013

How to request lists that contain certain items in MySQL

How to request lists that contain certain items in MySQL

In the application I am developing, the user has to set parameters to
define the end product he will get.
My tables look like this :
Categories
-------------
Id Name
1 Material
2 Color
3 Shape
Parameters
-------------
Id CategoryId Name
1 1 Wood
2 1 Plastic
3 1 Metal
4 2 Red
5 2 Green
6 2 Blue
7 3 Round
8 3 Square
9 3 Triangle
Combinations
-------------
Id
1
2
...
ParametersCombinations
----------------------
CombinationId ParameterId
1 1
1 4
1 7
2 1
2 5
2 7
Now only some combinations of parameters are available to the user. In my
example, he could get a red round wooden thingy or a green round wooden
thingy but not a blue one because I can't produce it.
Let's say the user selected wood and round parameters. How do I make a
request to know that there's only red and green available so I can disable
the blue option for him ? Or is there some better way to model my database
?

No comments:

Post a Comment