I’ve been told that it’s not good design to allow nulls in field definitions… I know it can cause errors… but can somebody please elaborate and explain under which circumstances I shouldn’t allow nulls and why. What’s the theory, what’s best practice? I want to understand.
EDIT
My dilema is that I have to make db changes now, and the code will be implemented later… so I’m concerned about creating new fields NOT NULL and risking non-field-specific INSERT statements failing. This is the area where I’m not clear. I want to allow NULL because I think it’s less risky, but others are telling me it’s bad design. At this stage I’m more concerned about minimising risk when the code is implemented. I’d appreciate if anyone would help clarify my choices for me. I’m lacking conviction and I need to make a decision soon.
That’s too simple. In many cases you don’t know – for example – if a person has children. NumberOfChilds = 0 means: He has zero children, NULL means: you don’t know.
But if you can make information mandatory in the whole process, it is good to enforce it on the deepest level.
Allowing NULL is better than having customers circumvent your logic, and marking a non-null-field with ‘-1 child’, to indicate “don’t know yet”. Now you’re lost if you take the sum. Or everybody invents his own secret code to patch your system.