logo

NULL Values

⇒ It is possible for tuples to have a NULL value for some of their attributes.

⇒ NULL signifies:

⇒ An unknown value or missing data, or

⇒ A value that does not exist.

Ex Example

Handling of NULL Values:

Arithmetic Expressions:

⇒ Any arithmetic expression (+, -, *, /) involving NULL results in NULL.

⇒ Example: 10 + NULL = NULL

⇒ Example: NULL * 20 = NULL

Aggregate Functions:

⇒ Aggregate functions ignore NULL values except for count.

⇒ Functions like avg, min, max, and sum exclude NULL values from their calculations but still count the total number of values.

Duplication and Grouping:

⇒ For duplication elimination and grouping, NULL is treated like any other value. Two NULL values are assumed to be the same.

Comparisons:

⇒ Comparisons (<, <=, >, >=, =, ≠) involving NULL evaluate to a special value called unknown (as in SQL).

⇒ Example: 5 = NULL, NULL > 5, 5 > NULL, NULL = NULL all result in unknown.

⇒ Because the outcome of these comparisons is neither true nor false, it is considered unknown.

Three-Valued Logic:

⇒ Boolean expressions involving AND, OR, and NOT use three-valued logic: true (1), false (0), and unknown.

OR Operation:

⇒ (unknown OR true) = true

⇒ (unknown OR false) = unknown

⇒ (unknown OR unknown) = unknown

AND Operation:

⇒ (true AND unknown) = unknown

⇒ (false AND unknown) = false

⇒ (unknown AND unknown) = unknown

NOT Operation:

⇒ (NOT unknown) = unknown

⇒ The result of a SELECT predicate is treated as false if it evaluates to unknown.

Next ❯ ❮ Previous
discription of faastop website
logo