NULL vs Empty when dealing with user input

前端 未结 8 1999
一整个雨季
一整个雨季 2021-02-06 11:57

Yes, another NULL vs empty string question.

I agree with the idea that NULL means not set, while empty string means \"a value that is empty\". Here\'s my problem: If the

8条回答
  •  礼貌的吻别
    2021-02-06 12:36

    I try to keep things simple. In this case, I'd make the first-name column not-nullable and allow blanks. Otherwise, you'll have three cases to deal with anywhere you refer to this field:

    1. Blank first name
    2. Null first name
    3. Non-blank first name

    If you go with 'blank is null' or 'null is blank' then you're down to two cases. Two cases are better than three.

    To further answer your question: the user entering data probably doesn't (and shouldn't) know anything about what a "null" is and how it compares to an "empty". This issue should be resolved cleanly and consistently in the system--not the UI.

提交回复
热议问题