Page 1 of 1

Making compatibility charts in MySQL

Posted: Mon Feb 27, 2006 8:30 am
by bwv2
I'm sort of new to databases and mySQL, but until now I've been able to find my way through it. Now I'm trying to make a compatibility chart of some kind in mySQL and I'm at a loss.

I would like to be able to find out which "widgets" are compatible with which "gadgets" that are for sale on my website. If a customer chooses a certain widget, the PHP script will automatically generate a list of compatible gadgets. In Excel, this would look like a matrix with Widgets across the top, and Gadgets down the side. Then there would be a series of x's in the matrix to show compatibility. How can I do this in mySQL?

I guess one way I could do it would be to actually make a table whose column names are Widgets and whose row names are Gadgets, then I could have an "x" at the intersection of each row/col that are compatible with one another. It just seems that there might be a cleaner way. As it stands, I have a table full of Widgets and a table full of Gadgets, each containing certain specifications. Is there any way I could somehow link compatibility between these tables? If not, I could certainly do it the way I described above. Let me know if you have any ideas. Thanks.

Posted: Mon Feb 27, 2006 8:38 am
by feyd
A table of widgets, gadgets, and one that references a widget and gadget, which will tell you they are compatible. This is called a many-to-many relationship for your information.