mysqlruby-on-railsdatabasepostgresqldatabase-design

Is better use an empty value as a '' or as NULL?


Database schema

I have this fields:

Is better set the default value as an empty string '' or a NULL?

For better reading/writing and size-storage performance


Solution

  • The usual contract is:

    Beyond this point there is much philosophical discussion since the invention of NULL in any language, not just SQL.

    The only technical point here is: In PostgreSQL NULL can be stored more efficiently than a string of length zero. If that really matters in your case ... we cannot know.