Exercise 1: Absence vs. NULL, and the Expiry-Alerts Query — Possible Solution ==================================================================== ABSENCE VS. NULL ------------------------------ In Firestore, a field being "absent" means the document simply doesn't include that key at all - there's no placeholder value stored for it. In SQL, a NULL column still exists as part of every row's fixed structure; it holds a special marker meaning "no value," but the column itself is always present. Firestore has no equivalent special marker built into the document by default - the field is either there with a real value, or it isn't part of the document at all. WHY A USED ITEM OMITS EXPIRYDATE RATHER THAN SETTING IT NULL ------------------------------ Per this chapter, omitting the field entirely means a range query like `where("expiryDate", "<", someDate)` automatically excludes that document from the results, because the query can only match documents where the field actually exists and is a comparable type. If the app instead stored `expiryDate: null`, it isn't guaranteed that Firestore's query engine treats that the same way for range comparisons - explicitly omitting the field is the deliberate, reliable way to guarantee a used item never accidentally matches an expiry-related query. HOW THIS AFFECTS THE CHAPTER 7 ALERTS QUERY ------------------------------ Because used items have no expiryDate field at all, Chapter 7's "expiring soon" query - which filters items by comparing expiryDate against a threshold date - naturally and automatically only ever considers active items. No extra status check is needed in that particular query just to exclude used items; the data model itself does that work. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly explains that Firestore models "no value" as the complete absence of a field rather than a null marker occupying an always-present column, and correctly connects that choice to how the Chapter 7 expiry-alerts query automatically excludes used items without additional filtering logic.