The stupid question is the question not asked | |
PerlMonks |
Re^2: mysql, checkbox, set, processingby shemp (Deacon) |
on Aug 31, 2005 at 21:24 UTC ( [id://488233]=note: print w/replies, xml ) | Need Help?? |
Yes, set seems like a good idea at first glance but it WILL bite you later on. When you set up the table definition, you specify all the values that are acceptable in the set. Then when you realize you need another valid value in the set, you need to alter the table definition. And you need to keep the original set items in the same order because the storage is actually numeric aliases, and when you redefine the column, it doesnt woory about the stored values. When you want to remove a value from the set the situation is worse, because then you can't retain the same positioning of all the set elements in the definition.
A much better solution is to use a lookup table with the valid values you'd put in the set. But you need an intermediate table to facilitate the many-to-many relation that occurs with a set. Similar arguements for the ENUM datatype, but easier to implement with the lookup table because there is no many-to-many relation. I use the most powerful debugger available: print!
In Section
Seekers of Perl Wisdom
|
|