Database – How will you handle NULL values in your application

databasenull

At what level do you prefer to handle Null values in your application?

My personal preference at the moment is the DB. When I build a view, I ensure that I return a value in place of a NULL value. So if your front-end app were to connect to the application it would never have to handle nulls.

In my VB6 apps, I made liberal use of the IsNull function to handle Nulls.

Share your experiences.

Best Answer

This is one of the problems with nulls. Whenever the database developer puts them into the database the application developer has to take them out again. Very often the best policy is to avoid or minimise the use of nulls in your base tables to start with. If nulls are used then it's a good idea to record somewhere exactly what the null is supposed to mean and why it is used. You can then put logic in a view or stored procedure to eliminate or replace the nulls as appropriate.