I have several tables that contain several strings for fields. Some of these fields may or may not always contain data. If I create a record with a string field that’s null at the time of the record’s creation, does it become a problem when I do a read query of that record because the field is null or does the query return an empty string?
What’s considered based? Non-nullabe strings or nullable strings, and when to know the difference?
Thanks for your suggestions.
The query will return an empty string if that is what is stored in the database and a null value (System.DBNull) if it is a nullable string with a null in it.
The decision, however, should be based on the data you are modeling, not the functionality of queries.
Null in a DB generally means that a value is either unknown or was left blank. This can be distinct from an empty string which could be used to mean there IS no value.
Take for example a MiddleName field. You might want to distinguish between someone with no middle name (empty string) and someone who didn’t enter it yet (Null). In this case you’d want a nullable string field.