treffynnon/sqlstyle.guide

Add advice for boolean columns?

danielcompton opened this issue · 4 comments

I looked through the style guide and couldn't see advice on columns that contain booleans. Do you have a preference for this, and would you be interested in adding it to the style guide?

Sorry, I meant to say naming advice, e.g. should you prefer is_shipped or shipped or has_shipped, e.t.c. There's different patterns for naming them and you have advice for other datatypes already, but I couldn't see anything for boolean columns?

I've been thinking about this and it's really only a problem in databases that don't natively support boolean columns (using maybe an int instead or perhaps an enum). If you're using an enum then it is possible that the _status suffix may make sense.

In a database that supports booleans it's unnecessary to indicate the type via the column name itself and it should just be shipped (using your example) in my opinion.

So, in short, I am of the opinion that booleans are not special and should follow the standard column naming guidelines.

Great, thanks!