Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- enum type, sort, restrict, use
January 11, 2006, 10:43 pm
rate this thread
it where I can.
Does anyone have WebApp experiences, that make life easier.
I can see applications for US states, phone types, order types, etc.
but for example
in a contact manager business phone types may differ than personal
I guess this column type is best used with a mutually exclusive,
defined, stable set of choices, and can be difficult to use otherwise.
Re: enum type, sort, restrict, use
That's not a good reason to use a data structure. A scalar variable is more
"efficient" than an array, but would you use a scalar where you need an
Correct. I would use enum only for fields where the list of values is by
definition immutable. The only one that comes to mind is defining an enum
of male/female for a non-nullable Gender column.
In most cases where I see people misusing enums, it would be better to have
an additional table containing the valid values, and where you would have
used an enum, instead use a foreign key. The reason is that in most cases
of misuse of enums, it's because the set of values are likely to change
during the lifetime of the application. It's very easy to change the values
by adding a row to a lookup table, but it's awkward and risky to adjust your
enum definition every time this happens.
If you use a lookup table instead of an enum, it's very easy to get the list
of valid values.
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum