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 reply to Re^2: mysql, checkbox, set, processing by shemp
in thread mysql, checkbox, set, processing by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.