Exercise 1: Why the Date Comparison Depends on Consistent YYYY-MM-DD Formatting — Possible Solution ==================================================================== WHY IT ONLY WORKS BECAUSE OF THE CONSISTENT FORMAT ------------------------------ SQLite has no dedicated date type - expiry_date is stored as plain TEXT, and the <= operator between two TEXT values compares them character by character (lexicographically), not according to any actual calendar logic. The YYYY-MM-DD format happens to be one of the rare date formats where comparing the text character by character gives exactly the same result as comparing the dates chronologically - year digits come first, then month, then day, all fixed-width, so lexicographic order and chronological order agree. WHAT WOULD HAPPEN WITH A DIFFERENT FORMAT ------------------------------ If even one date were stored as, for example, MM/DD/YYYY instead, a lexicographic comparison would no longer match chronological order - "12/01/2026" would sort before "03/15/2026" as plain text, even though March comes before December. The query would silently return the wrong rows - no error, no crash, just incorrect results that could easily go unnoticed until someone checked the actual expiry dates against what the alerts list showed. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly explains that TEXT columns compare lexicographically rather than chronologically, correctly identifies that YYYY-MM-DD is one of the formats where those two orderings happen to coincide, and correctly describes the silent, no-error nature of the failure that a mixed date format would cause.