Page 1 of 1
mysql field types : ENUM, SET
Posted: Tue May 11, 2004 3:17 pm
by mudkicker
hi mates,
just wanna ask about these two field types :
where should i use them and how? i read the mysql manual but can't get a good info about it..
Posted: Tue May 11, 2004 5:14 pm
by Weirdan
obviously, enum are used when you have column with enumerable allowed values
f.e. I have
log table in my db, which contains log entries for my web app. It has '
type' column of type
enum with allowed values:
fatall,
warning,
note eg each record has some type, either fatal, warning or note.
There is another column,
status of type
set with allowed values:
read,
sent,
flagged eg each record can be sent and/or read and/or flagged.
It might be not the best example, but it works for me...
Posted: Wed May 12, 2004 4:31 am
by mudkicker
ok thanks weirdan,
if it's so, does it make any difference?
fore example i want to you ise for a yes or no question sotred in db.
i mean i ask in form, if user needs a picture. if yes it will be stored for yes or no.
if there's no difference between using set,enum etc. or doin it wit 0,1 (1 if yes)...
Posted: Wed May 12, 2004 8:47 am
by launchcode
There's no real difference other than the fact it's easier to read "yes", "no" than 1,0 (especially if you have lots more options than that). From MySQL's point of view - an enum is extremely fast because it knows the allowed values already, so bare that in mind too.
Posted: Wed May 12, 2004 1:09 pm
by mudkicker
hmm. thanks people i got it!