Difference Between Field Properties (isNullable vs required)?

757
3
Jump to solution
07-25-2019 02:54 PM
MicahBabinski
Regular Contributor

I'm confused about the difference between two field properties: isNullable vs. required. Looking at the docs for a field object, I see both listed:

isNullable:

required:

What is the purpose of having both of these properties? I ask because I am analyzing a dataset with a field where isNullable = True, and required = True.

Shouldn't a field that allows null values be considered non-required?

Thanks to anyone who can clear this up for me!

0 Kudos
1 Solution

Accepted Solutions
LanceCole
MVP Regular Contributor

Micah Babinski‌,

I had to think about this question.  Do not consider of Nullable and Required as related to each other as they serve totally different functions. 

Nullable and Non-Nullable pertains to when a value is not provided for a field the database will automatically populate the field with a <NULL> for Nullable or a zero (0) for numbers and an empty string ("") for text for Non-Nullable fields.

Required pertains to the field (the column) in a table not the values stored in the field.  When you select Required you cannot delete or remove the field or column from the table.  The Delete Field option will be grayed out for this column in the table.  The values in the field still can contain NULLs if the field is also set to Nullable or will contain 0 and "" for Non-Nullable.  A good example of the use of Required would be to prevent a user from accidently deleting a field that is used by other functions or programs. 

The image below shows a field in a table that is set to Required and Allow Nulls.  You can see there are Null values in the table but if I try to delete the field, the option is disabled.

View solution in original post

3 Replies
LanceCole
MVP Regular Contributor

Micah Babinski‌,

I had to think about this question.  Do not consider of Nullable and Required as related to each other as they serve totally different functions. 

Nullable and Non-Nullable pertains to when a value is not provided for a field the database will automatically populate the field with a <NULL> for Nullable or a zero (0) for numbers and an empty string ("") for text for Non-Nullable fields.

Required pertains to the field (the column) in a table not the values stored in the field.  When you select Required you cannot delete or remove the field or column from the table.  The Delete Field option will be grayed out for this column in the table.  The values in the field still can contain NULLs if the field is also set to Nullable or will contain 0 and "" for Non-Nullable.  A good example of the use of Required would be to prevent a user from accidently deleting a field that is used by other functions or programs. 

The image below shows a field in a table that is set to Required and Allow Nulls.  You can see there are Null values in the table but if I try to delete the field, the option is disabled.

MicahBabinski
Regular Contributor

Thanks Lance! I now see that in the field_is_required parameter description of the Add Field tool. Your explanation is far superior! This will save me a lot of confusion and investigation time at work.

Cheers,

Micah

0 Kudos
DanaNolan
Regular Contributor

Additionally, the Is Required property essentially only works inside the database you are working in, i.e. if you export data from the database, this will be lost and people will be able to delete the field in their copy (makes sense). Is Nullable transfers with the data when it is moved/copied around.

0 Kudos