List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:August 14 2001 3:52pm
Subject:Re: BIT data type?
View as plain text  
You could use a separate flags table that contains the
parent record key, flag name, and flag value.

You can then add and delete flags at will.

Philip Mak wrote:

> I have an application that requires the storage of various flags (by
> "flag", I mean a variable that is either 1 or 0).
> What's a good way of doing this? I've thought about two ways:
> Method 1: Make a TINYINT column for each flag
> I can use TINYINT NOT NULL datatype for storing each flag. The
> disadvantage is that I use 8 bits when 1 bit would have sufficed.
> Method 2: Make a single SET column for all the flags
> I can use a SET for storing all the flags. But the disadvantage is that
> the programming syntax gets a bit more complicated. e.g. instead of being
> able to do:
> SELECT * FROM fanfics WHERE unfinished = 0
> I would have to do:
> SELECT * FROM fanfics WHERE FIND_IN_SET('unfinished', flags) = 0
> Does anyone have other suggestions?
> Another concern that I have is the time required to add a new flag. If I
> have a large table, adding a new column to the table can be quite time
> consuming. (I'm guessing if I use the SET method, adding a new flag would
> be instantaneous unless the number of flags was divisible by 8, requiring
> the SET to expand by one byte.)
> ---------------------------------------------------------------------
> Before posting, please check:
>   (the manual)
>           (the list archive)
> To request this thread, e-mail <mysql-thread82502@stripped>
> To unsubscribe, e-mail
> <>
> Trouble unsubscribing? Try:

Gerald L. Clark

BIT data type?Philip Mak14 Aug
  • Re: BIT data type?Gerald Clark14 Aug