NULL Value

Context: FIT2094_MOC · a marker that a value is absent, not a value itself · an SQL feature, not classical relational algebra · four distinct reasons

Quick Revision

  • 🎯 Objective: a marker that a value is absent/not applicable âž” not a value itself.
  • 📦 Core Components: four reasons âž” not applicable / unknown / does not exist / undefined.
  • ⚡ Key Constraint: NULL ≠ 0 ≠ empty string; an SQL feature, outside classical Relational Algebra.

📝 Core

1. The Marker

  • Definition âž” a value does not exist / is not applicable for a tuple — not a value.
  • SQL only âž” classical Relational Algebra has no NULLs (assumes complete info).

2. Four Reasons

  • Not applicable âž” attribute doesn’t apply (non-sales employee’s commission; 0 would be wrong).
  • Unknown âž” value exists but not yet known (new employee’s salary).
  • Does not exist âž” genuinely absent (no tax file number yet).
  • Undefined âž” explicitly undefined (average payment before any payment).

3. Not Zero / Not Empty

  • NULL ≠ 0 âž” 0 is a value; NULL is absence.
  • NULL ≠ ” âž” empty string is a value too.

⚙️ Core Implementation

🔹 The four reasons (worked)

When It Flips: entity integrity forbids a NULL primary key; referential integrity permits a NULL foreign key (optional participation). Comparisons/aggregates over NULLs need three-valued logic — an extension of FIT1058 two-valued logic.

📊 Exam Execution Trace

Manual Execution Trace

Classifying NULLs:

Step / StateCaseReason
0 (Init)——
1warehouse commissionnot applicable
2new employee salaryunknown
3no tfndoes not exist

Applied Exercise

Problem: A non-sales employee has no commission. Is commission = 0 correct? Derivation Proof / Hand-Calculation Walkthrough:

Final Extracted Output: incorrect — use NULL, not 0; the attribute does not apply.

đź§  Active Recall