Boolean Columns Answer Too Few Questions

One of the things that I dislike seeing in an application’s database architecture is the use of booleans. They do not convey enough information to any party to be meaningful, other than to ask a question that expects a yes/no answer. Often, questions such as those as a follow-up question that the field cannot answer. For example, in many databases I see the following fields on a User model: User ==== id primary key username the user's username credential password_encrypted authenticates the username ... other fields ... enabled true if the user is active, false otherwise When a user has been banned for doing something inappropriate, an application simply sends this query: ...

September 8, 2014 · 3 min · 563 words · Scott Brown

Making Fool-Proof Dynamic SQL

I was reading the MyBatis docs as a refresher and in the Dynamic SQL section I noticed that they are still struggling with the WHERE clause if all elements are conditional. Take this example from the docs: It says that if none of the conditions are met, you will end up with an invalid SQL statement of SELECT * FROM BLOG WHERE or in another case SELECT * FROM BLOG WHERE AND title like #{title}. Both of these are a common problem when trying to build a dynamic SQL statement. ...

August 27, 2013 · 2 min · 268 words · Scott Brown