I dodged a heated debate concerning nulls in the database today.
我的观点是,空值是一个很好的未指定值的指示器。团队中其他人都认为零和空字符串是前进的方法。
Are they lazy or am I too strict?
I dodged a heated debate concerning nulls in the database today.
我的观点是,空值是一个很好的未指定值的指示器。团队中其他人都认为零和空字符串是前进的方法。
Are they lazy or am I too strict?
They are lazy and do not understand the basic idea of a null in the database. Nulls are useful and have a purpose. They should neither be avoided nor used inappropriately.
null意味着没有值,而0则不是,如果你看到一个0,你不知道它的意义,如果你看到一个null,你知道它是一个缺失值。
我认为空值更清晰,0和 令人困惑,因为它们不能清楚地显示存储的值的意图。
如果未指定,那么null是一个很好的指示器,零是有意义的,而null不是。我不是专业的数据库专家。
Despite the extra work that using nulls requires I think there SHOULD be a difference between a non specified field and a field set to empty or 0.
除了你,还有谁能说用户故意将值设置为0,或者他没有设置该字段?