Null in Applications
Understand how to manage null values in PostgreSQL by applying not null constraints and using proper SQL syntax. This lesson explores the implications of nulls in applications, guides you through avoiding unwanted null entries, and explains correct query methods using three-valued logic to ensure accurate data retrieval.
The not null constraint
In some cases, we want a strong guarantee that a column cannot be null in our data model. Usually, that’s because it makes no sense for our application to deal with some unknowns. In other words, we want to know if we are dealing with a required value.
Evading the not null constraint
Unless we specify something else, the default value for any column is always null. However, it’s only a default value; it’s not a constraint on our data model, so our application may insert a null value in a column with a ...