Skip to main content
added 57 characters in body
Source Link
Robert Harvey
  • 200.7k
  • 55
  • 470
  • 683

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

One of my university lecturers described it like this:

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them two. The sales guy suggested I just give a false one. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, Longitude, Latitude) ... "longitude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longitude, latitude) the entire record is meaningless if longitude and latitude are null. Therefore in this instance they should be not-null

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them two. The sales guy suggested I just give a false one. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, Longitude, Latitude) ... "longitude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longitude, latitude) the entire record is meaningless if longitude and latitude are null. Therefore in this instance they should be not-null

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

One of my university lecturers described it like this:

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them two. The sales guy suggested I just give a false one. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, Longitude, Latitude) ... "longitude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longitude, latitude) the entire record is meaningless if longitude and latitude are null. Therefore in this instance they should be not-null

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

deleted 4 characters in body
Source Link

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them two. The sales guy suggested I just give a false one. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, LongditudeLongitude, Latitude) ... "longditude""longitude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longditudelongitude, latitude) the entire record is meaningless if longditudelongitude and latitude are null. Therefore in this instance they should be not-null

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them two. The sales guy suggested I just give a false one. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, Longditude, Latitude) ... "longditude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longditude, latitude) the entire record is meaningless if longditude and latitude are null. Therefore in this instance they should be not-null

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them two. The sales guy suggested I just give a false one. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, Longitude, Latitude) ... "longitude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longitude, latitude) the entire record is meaningless if longitude and latitude are null. Therefore in this instance they should be not-null

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

added 28 characters in body
Source Link

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them at least onetwo. The sales guy suggested I just give a false numberone. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, Longditude, Latitude) ... "longditude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longditude, latitude) the entire record is meaningless if longditude and latitude are null. Therefore in this instance they should be not-null

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them at least one false number. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, Longditude, Latitude) ... "longditude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longditude, latitude) the entire record is meaningless if longditude and latitude are null.

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

At Uni I was taught that the opposite is true. It's much more dangerous to make something not null without reason. With a nullable field the worst thing that can happen is you trip over the application accessing the data. Oh dear, go back and fix the app...

With a not-null field you make it impossible to add record because some arbitrary field isn't available. Now you need to change the data model and potentially fix the result in a LOT of different places...

It's good to think of null as "unknown". If there's any plausible reason why you might want to enter a record without knowing something then it should be nullable.

Apocryphally I've heard of a sales system in the USA which required customer's social security number to make a sale. All the till operators did when a foreigner came to the till was enter 000-00-0000. But then others would enter 123-45-6789. This makes it impossible to identify junk. It's much better to allow a field to be blank than to force it to contain junk.

Or another story. I have genuinely been refused car insurance because I don't have two phone numbers. They absolutely would not give me insurance unless I gave them two. The sales guy suggested I just give a false one. In the end I refused to lie to an insurer and just went with another company.

In practice reserve not null for fields which are required to make sense of the record. For example:

A table of places with fields (ID, Place Name, Country, Longditude, Latitude) ... "longditude" "latitude" should be nullable so that you can store the existence of a place before you know where it is.

But if you have a table who's sole purpose is to store geographical coodinates with fields (Item_id, longditude, latitude) the entire record is meaningless if longditude and latitude are null. Therefore in this instance they should be not-null

In my professional experience since uni, there are far more fields which can optional than need to be mandatory.

deleted 9 characters in body
Source Link
Loading
added 377 characters in body
Source Link
Loading
Source Link
Loading