Few things, first of all, we'll take your way of doing it.
Now, a year down the road the boss says ' I want people to be able to search for things based on their shape / size / color '
Well, if we're using your strategy, we're screwed. We can't do any simple search to be able to search by shape, or size, or color! We could use a LIKE '%shapehere%' statement, but its slow, and definitally not an elegant solution.
If we were using mine, we can just search on one field, for an exact match. Or better yet, if we have another table of shapes:
Shapes
ID, shape
And change the original table to:
ID, color, shape_ID ( and add an Index to this if you want ), taste
We can do super fast searches and dont' have to worry about ugly LIKE statements, not to mention my way is normalized adn uses good database practices that the intellectual / educated type like too.
Secondly... I didn't use 4 tables. I used one table with 4 columns... not sure where you got that...
Also, why make a table with one column when you can make one with 4? It's not like 4 columsn will be stressing the database any...
Also, multiple tables is GENERALLY ( but not always ) a very bad idea for a bunch of categories. Usually its done like this:
Table - Categories -
ID, parent_ID, depth, name
So, for the base categories you have:
1, 0, 0, Computers
2, 0, 0, Fruits
Then you have subcategories of computers:
3, 1 ( the ID of computers is it's parent ), 1 ( its one level deep ), Hardware
4, 1, 1, Software
5, 2, 1, Apples
6, 2, 1, Oranges
7, 2, 1, Bananas
Then subcategories of those subcategories:
8, 3 ( hardware is it's parent ), 2 ( two levels deep now ), Video Cards
9, 3, 2, Motherboards
10, 3, 2, SCSI Cards
etc. etc. etc.
BUT, if you insist, these functions will be helpful to you:
www.php.net/serialize
www.php.net/var_dump
Most likely, you'll have to write yoru own little arcance foreach() looop to loop through the array and build a set of stuff like you did... but I'll warn ya, you're doing it the hard way :-)