| Author |
Store flags in MySQL?
|
Ivan Jouikov
Ranch Hand
Joined: Jul 22, 2003
Posts: 269
|
|
what's a good variable type to store flags? I guess you can do TEXT or VARCHAR(255) and have unique words in it, but that's a little inefficient... int bits are a bit confusing.... Anything you can suggest?
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
|
I think you should be posting this question in JDBC forum.
|
Groovy
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56197
|
|
|
Quite correct... moved.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Jason Steele
Ranch Hand
Joined: Apr 25, 2003
Posts: 100
|
|
Well, Since, generally flags are (on or off) or (1 or 0) or some similar pattern, I would go with tinyint. Could you be more specific?
|
An egg is a chicken's house!
|
 |
Ivan Jouikov
Ranch Hand
Joined: Jul 22, 2003
Posts: 269
|
|
Well... If for instance I wanted a whole bunch of flags, like "user owns this, user can delete this, user can modify this, etc", would I have to create a separate column for each and every one? I mean as I go along, I might get more and more flags, and I don't think it would be cool to have 30 columns in there, most of which would be barely used...
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Why don't you create a FLAG_TABLE with 2 columns. FLAG_ID FLAG_DESC Then wherever you needed a flag, use the FLAG_ID from the FLAG_TABLE.
|
 |
Dana Hanna
Ranch Hand
Joined: Feb 28, 2003
Posts: 227
|
|
|
You could use bits on an INT (my preferred approach), or a seperate "USER_SECURITY" table, with tons of fields. Either way, abstract it in your code such that it can change later on.
|
 |
 |
|
|
subject: Store flags in MySQL?
|
|
|