> I'm making this web site, where the owner or administrator will be able to > upload new products and these products come in different sizes. Now, I > made > a table in MySQL o store the products but only with a VARCHAR field where > the administrator will store the sizes like "12, 14, 16 and 18". > > I would like to store the sizes for each product in a different table, but > my question refers on how to do this... one product per row with all the > different sizes (which will leave too many blank fields in every row) or > one size per row, making several rows per product.
Sounds like you want a SET column, where you can define the different values it can contain and it can contain any of those values. So, if you have a SET(12,14,16,18) column, it can have values like '12,18' and '14,16,18' and '12', etc... You can then use functions such as FIND_IN_SET to quickly look for specific values. Note that this would be quicker than using a plain VARCHAR column to store a comma separated string. Or, you could have a 'size' table where you store the Item_ID and a size. So you'd have rows like this: +------+------+ | Item | Size | +------+------+ | 1| 12| | 1| 14| | 2| 14| | 3| 16| | 3| 18| +------+------+ And do JOINs to find your relevant data. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php