SQL for Smarties | SQL Programming Style | Trees and Hierarchies in SQL | SQL Puzzles and Answers | Data and Databases


Thursday, July 06, 2006

Two Boolean Columns Per Attribute

SQL Apprentice Question
I'm analyzing an existing database that has many fundamental design
problems. One of the more "intriguing" findings is that there are many cases
(157) where there are two Boolean columns for a single Boolean attribute.
For example, the attribute "likes ice cream" would be stored in two columns,
named something like:

LikesIceCreamY
LikesIceCreamN


each of the bit data type.


Many of the rows in the table have different values in the columns, many
have identical values.


My question: Could there be any good reason to do this?



Celko Answers
>> One of the more "intriguing" findings is that there are many cases (157) where there are two Boolean columns for a single Boolean attribute. <<


Nope, the only reason I can think of is that the guy who did this was
an old assembly language programmer who wants to make one column per
radio button. I think you will that it needs more repairs than just
putting them in the same BIT. Think about designing actual encoding
schemes for the atttributes.

No comments: