
Nullable columns in a database should be used with caution. When a table contains a lot of NULL values, they are difficult to work with: you have to remember to account for NULL values when writing queries and writing code (in many programming languages, they will result in a NullPointerException
).
If many columns in a table are nullable, sometimes it is a good idea to move these optional fields into a separate table and leave only a nullable link to the new table.
Let’s see this in action. Imagine a system with some optional user settings. Instead of storing mandatory fields and optional settings in one user
table, we can create a separate user_settings
table:

All of the fields in the user_settings
table can be assigned a NULL value. Both tables are connected with a foreign key constraint which is also nullable (in case the user does not have any optional settings configured).
How to Make a Column Nullable in Vertabelo
Click on the table. In the right pane, look for the Columns section. Find the column you want to make nullable and check the N box next to it.