▲ | lblume a day ago | |||||||||||||
> But a field that is nullable in the schema and never null in practice is a silent lie. This seems to be the central claim. But just as lies require intent, so does database design to some degree. A column that is nullable but never null does not conclusively say anything, really. That's like saying a birthday column that is never before 1970 in the current data should be restricted to years after that date. A nullable column signals that the data may be left empty, which is entirely different from that column actually having to be empty with the current data. Is-ought distinction, the potentiality of null ("nullability") is not to be confused with the actuality of current vacancy ("null values"). The programmer extracting data from the database must check for null if the data is nullable, not just if is null now as a principle of robust fault-tolerant code. | ||||||||||||||
▲ | jerf a day ago | parent | next [-] | |||||||||||||
I don't think the author is talking generally about fields that could be NULL but just happen to never be so in the production DB. The piece is specifically in the context of a new database field that is fully intended by its designer to be NOT NULL, which was NULL only for migration purposes, and which was never updated to be NOT NULL once the migration is complete. The point was not meant to be extended beyond that. One could write a separate piece about maybe using that as a clue that the field could be NOT NULL'd in the future but that's not what this post is. | ||||||||||||||
| ||||||||||||||
▲ | dataflow a day ago | parent | prev | next [-] | |||||||||||||
> That's like saying a birthday column that is never before 1970 in the current data should be restricted to years after that date. No it's not, because they specifically started with the premise that the field was initially intentionally non-null and was only temporarily made nullable for migration purposes. That is obviously not the situation you are describing, right? | ||||||||||||||
▲ | darkwater a day ago | parent | prev | next [-] | |||||||||||||
I think their point is that for all intents, the column IS not nullable. It's nullable as an artifact of making live schema migration easier, with no blocking/downtime. But as the data model is concerned, it should not be nullable. | ||||||||||||||
| ||||||||||||||
▲ | matsemann a day ago | parent | prev [-] | |||||||||||||
Problem is you end up other places with the assumption thar it's never null. So in the future when you actually set it to null somewhere it will blow up. | ||||||||||||||
|