Database Design: 3-State Bits

I can hear you thinking, “Andy, you’re off your old rocker. There are only two states for bit values!” And you are correct. Almost.

What if I’m storing a truly binary value – a value that possesses only two possible states – but there’s the possibility of a third state to indicate that I do not know which state applies. Consider this single-column example table:

[Value]
High
Low
Don’t Know or Don’t Care

The two discrete states are High and Low. The 3rd state can be labeled “unknown.” Can I represent these three states using a bit data type?

Yes!

I can do it with a NULL:

[Value]
1
0
NULL

NULL means “the data is missing.” But in this context, I can define NULL to mean “unknown.” One caveat is that I cannot define to NULL to mean both “missing” and “unknown.” I have to pick one and only one meaning for NULL.

:{>

Andy Leonard

andyleonard.blog

Christian, husband, dad, grandpa, Data Philosopher, Data Engineer, Azure Data Factory, SSIS guy, and farmer. I was cloud before cloud was cool. :{>

One thought on “Database Design: 3-State Bits

  1. Not something I’ve looked into, but what happens with null in bitwise operations?
    Also, I see the 2016 announcement suggests dynamic obfuscation, which I really hope means what it sounds like it means… but have you heard how that might work with bits?
    🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.