Can Microsoft store three-valued fields in a single bit?

Posted by fenomas on Stack Overflow See other posts from Stack Overflow or by fenomas
Published on 2010-06-02T03:00:06Z Indexed on 2010/06/02 3:03 UTC
Read the original article Hit count: 374

Filed under:
|
|
|

I'm completely ignorant of SQL/databases, but I was chatting with a friend who does a lot of database work about how some databases use a "boolean" field that can take a value of NULL in addition to true and false.

Regarding this, he made a comment along these lines: "To Microsoft's credit, they have never referred to that kind of field as a boolean, they just call it a bit. And it's a true bit - if you have eight or fewer bit fields in a record, it only requires one byte to store them all."

Naturally that seems impossible to me - if the field can hold three values you're not going to fit eight of them into a byte. My friend agreed that it seemed odd, but begged ignorance of the low-level internals and said that so far as he knew, such fields can hold three values when viewed from the SQL side, and it does work out to require a byte of storage. I imagine one of us has a wire crossed. Can anyone explain what's really going on here?

© Stack Overflow or respective owner

Related posts about database

Related posts about null