IMHO, it is better to use ints for masks because they can be indexed by the database. AFAIK, bits can't be indexed and any bit operator in a query (let's say, "WHERE mybit & MYMASK") would probably result in a full table scan.

well, it's just my two cents from an info I got a long time ago. I might be wrong now, so ...


best regards,
Richard.

On 08/27/2015 06:54 AM, Cornelius Kölbel wrote:
Hello,

this is maybe more about the database design.

I want to store several boolean states of an object.
The object may also have more than one state and the available possible
states may increase in future.
So I want to avoid adding BOOL columns for every new state and I though,
hey, what about bit fields - one column, that can store many boolean
information/flags.

I understand that MySQL provides a datatype BIT, but which may lead to
problems, depending on the version and table type.
What about sqlalchemy?
Is there a reasonable way to use bit masks?

Would you recommend anyway to avoid such a design, since it is not that
what SQL originally was designed for?
I also want the program to be able to run on mysql or postgres or
whatever. So maybe choosing bit masks is a bad idea anyway, since it
might lead to problems with different database backends?

Thanks a lot for your thoughts
Cornelius


--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

<<attachment: richard.vcf>>

Reply via email to