Normally could it be sound practice to create all database posts as NOT NULL or otherwise ? Justify the way to go.

No. It's wise to create posts to NULL where appropriate.

I type of disagree using the "where appropriate" rule. It's really rather safe to create any column to become NOT NULL after which later customize the posts to permit NULL values when you really need them. However, should you allow NULL values first after which later decide you won't want to permit them, it may potentially considerably harder to get this done.

It might build your database table/column explanations quite ugly should you choose this excessively, however when uncertain, proceed and restrict the information.

Relational theory has it that NULL is evil.

However, your question type of known to rehearse.

So, towards the extent that you would like your practices to adapt towards the heavenly beliefs in theory, yes, avoid NULL as though it were the plague and also the cholera and helps all-in-one.

Towards the extent these crappy implementations known as "SQL dbms" don't make you every other choice, yes, (snif) rely on them.


Someone pointed out "business rules" because the guideline for "appropiateness" within the accpeted answer, plus some others upvoted that remark. That's total garbage. Business rules can invariably do without nulls and also the only guideline to "suitability" may be the very inadequacies associated with a SQL system that causes it to be a non-relational system as well.

From the perspective, although it might be better for that database, it isn't better for that user. When you enter into more interactive programs, you need to have the ability to persist the information within an interim condition, so much of your fields will most likely be null at that time.

If you cannot be aware of value at place time, you actually should have a null permitted. For example, suppose you havea record which includes two fields, begin date and finish date. You realize begin date once the record is placed although not the finish date. Developing a fake date to set up this area simply to avoid nulls is dumb as you would expect.

In tangible existence a minimum of just as much harm is triggered by forcing data entry right into a area as by not forcing it. Should you havea an e-mail area and do not be aware of customer's email, then your user needs to make something as much as put in the needed area. Likely the things they constitute might not be what you will would like them to create up something similar to "". Sometimes this bad info will get provided to the customer in order to a vendor inside a data feed as well as your company looks really really stupid. I understand when i process many of these feeds arriving from your clients. Nice things within the email area have incorporated, "his secretary may be the body fat blonde", "this person is really a jerk" etc.

Short answer: it is dependent on what you're storing.

I can tell a table (or two) getting all NOT NULLS or all NULLS. But a whole database?

Just for posts where not getting something does not make sense at all.

Nulls can be quite handy to begin with, they compress superbly. They may be an awful surprise whenever you pricier them, though, if you can't possess a Student with no Name -- make that column NOT NULL. (Middle names, however... maybe you need to possess a default empty string, not -- decent arguments for both)

You shouldn't forget to create not null where needed, use check constraints if relevant, remember about unique constraints, create proper indexes and brush your teeth after each meal and before going to sleep:)

Generally you should use not null and you ought to use not null. It's simpler to alter not null->null compared to other direction, but for instance in Oracle empty string is treated as null, so it's apparent that you simply can't utilize it constantly.