I've got a table with several posts.

Sometimes a few of these column fields might be empty (ie. I will not rely on them in some instances).

My questions:

  1. Will it be wise to create these to NULL in phpmyadmin?

  2. Exactly what does the "NULL" property really do?

  3. Would I gain anything whatsoever by setting these to NULL?

  4. Can you really make use of a NULL area exactly the same way despite the fact that it's set to null?

The idea of the NULL value is a very common supply of confusion for beginners to SQL, who frequently believe that NULL is equivalent to a clear string '', or perhaps a worth of zero.

This isn't the situation. Conceptually, NULL means "military services weapons unknown value" which is treated somewhat in a different way using their company values. For instance, to check for NULL, you can't make use of the arithmetic comparison operators for example =, <, or <>.

For those who have posts that could contain "military services weapons unknown value", you need to set these to accept NULLs.

However, a table with lots of NULL posts might be showing this table must be refactored into more compact tables that better describe the organizations they represent.

I suggest you read Issues with NULL Values.

Going to try and answer the questions you have all at one time here.

NULL signifies something like "Unknown"/"No value" or "Not relevant". So yes, if you will find posts which are unused in a few conditions, it might be appropriate to create these to NULL if not used (as not one other value is suitable).

You'll be able to constrain a column not to NULL, and therefore the column must possess a value for every row. A good example would the "title" column of the "person" record. It does not seem sensible for any title to become NULL, as everyone includes a title.

You can "use" a NULL column, just bear in mind you need to be careful when you are performing evaluations. A NULL area isn't comparable to another area. Look for "IS NULL" or "Isn't NULL".

1- Will it be wise to create these to NULL in phpmyadmin?

All fields are null automatically unless of course you specify a default value on their behalf or place some value on their behalf. You don't need to do that...

2 -Exactly what does the "NULL" property really do?

Null implies that you haven't designated any value into it.

3- Would I gain anything whatsoever by setting these to NULL?

As stated before, all fields are null automatically unless of course you specify a default value on their behalf or place some value on their behalf. I do not think you will gain anything.

4- Can you really make use of a NULL area exactly the same way despite the fact that it's set to null?

What can you will get from a area getting worth of NULL? No requirement for that as well.

Brief solutions for your questions:

  1. Yes, NULL implies that the area consists of nothing whatsoever. In the event that's the real situation, that is what the information should say. A good example will be the shipped_date to have an order that has not shipped. Within this situation, NULL would precisely represent the worthiness before the order ships out, since until it will there is not a legitimate time where it did (as well as in this situation, checking for that NULL value may be a significant valuable tool in identifying which orders still have to be shipped).

  2. NULL implies that the area consists of nothing. "Nothing" differs from, say, the worthiness or even the string "", because these are values. NULL means roughly exactly the same factor as "N/A" or "I decline to reply toInch. Just what this means is context determined by the column. Obviously, some posts will not be NULL, and you will enforce by using your table design.

  3. If the majority of the fields inside a column are NULL, you need to re-think just how you are by using their column. In most cases, a lot of NULL values signifies you can design your tables better. Regarding defaulting, you could set a nullable value to default to NULL.

  4. Exactly the same way as what? NULL is really a unique value. It isn't equal to , or "", or other things like this. Inside a query, you should check for IS NULL or perhaps is NOT NULL, and when a null is drawn in a dataset, you should check for this particularly there too. Asking if your column set to NULL is equivalent to , or "", or whoever else, will return false.