Encode PDF 417 in Font Dealing with Nulls

Using Barcode creation for Font Control to generate, create Barcode image in Font applications.

www.OnBarcode.com

The example data in the Member table shown earlier in Figure 2-2 is all very accurate and complete. Every row has a value for each attribute except for Handicap, which doesn t apply to some members. Real data is usually not so clean. Let s consider some different data, as in Figure 2-5.

Using Barcode drawer for Font Control to generate, create International Standard Serial Number image in Font applications.

www.OnBarcode.com

When there is no value in a cell in a table, it is said to be Null. Nulls can cause a few headaches in a database. For example, if we ran two queries, one to produce a list of male members and the other a list of females, we might assume that all the members of the club would appear on one list or the other. However, for the data in Figure 2-5, we would miss Kim Jones. Now, you could argue that the data shouldn t be like that but we are talking about real people and real clubs with less than accurate and complete data. Maybe Kim forgot (or refused) to fill in the gender part of the application form. It is possible to insist that Nulls are not allowed in a field when we create a table. Listing 2-17 shows how we could make Gender a field that always requires a value.

Using Barcode generation for Java Control to generate, create DataMatrix image in Java applications.

www.OnBarcode.com

It is worth bearing in mind, however, that making fields required can create more headaches than it cures. If Kim Jones did not fill all the boxes on his/her membership application but sent a bank draft for the subscription, then we want to make him/her a member and worry about the full details later. However, if we make Gender a required field, then we can t enter a record for him/her in the table or we have to guess what his/her gender is. Neither of these options is very good, so it is best to be sparing about making fields required. Remember that our primary key fields (by definition) always need a value. Not all values of Null mean there is a problem with the data. In our Member table, a field might be Null because it does not apply to a particular member. Sarah Beck s handicap may be genuinely Null because she does not have a handicap. However, it is fair to assume that every member should have a value for MemberType and Gender, so the Nulls in these columns are because we do not know the value. In the real world, therefore, expect that your tables will have missing data.

Using Barcode maker for Reporting Service Control to generate, create Barcode image in Reporting Service applications.

www.OnBarcode.com

Listing 2-18. What Rows Will Match Each of These Conditions Gender = 'F' NOT (Gender = 'F')

If we run two queries with the conditions in Listing 2-18, will we get all the rows in the table You might think that if we get all the rows that match a condition and all the ones that don t, then we will get the lot. But in fact we don t. Kim will not be included with the first condition because clearly the value of Gender does not equal F , But when we ask whether the value is NOT ( F ), we can t say because we don t know what the value is. It might be F if it had a value. This probably makes more sense if we think about handicaps. If we ask for everyone with Handicap > 12, NOT (Handicap > 12), or Handicap <=12, then Sarah s row will never be retrieved because the question doesn t apply to her she doesn t have a handicap. So once we take Nulls into consideration, our expressions for conditions might actually have one of three values: True, False, or don t know. That is pretty much how the world actually works if you think about it. Only rows that are True for a condition are retrieved in a query. If the condition is False or if we don t know, then the row is not retrieved. The truth tables, when we include don t know, look like those in Figure 2-6. For an AND operation, if one expression is False, then it doesn t matter about the others the result will be False. For an OR operation, if one expression is True, then it doesn t matter about the others, so the result will be True.