Premier League Predictor: FastAPI & Redis — Chapter 7, Exercise 1 ================================================================= TASK Build three small cases: two teams level on points and goal difference but different on goals scored; two teams level on all three keys; and two teams level on points but different on goal difference. Report the real table order for each and say which key or fallback decided it. SOLUTION Each case used a fresh 4-team table (padded IDs 001-004, all starting at score -500000) and the chapter's APPLY_RESULT script. Case A - level on points and goal difference, different goals scored Team 1 beat team 3 by 3-2 (GD +1, GF 3); team 2 beat team 4 by 1-0 (GD +1, GF 1). Order: 001 (-3501003), 002 (-3501001), 003, 004 Decided by goals scored: 3 beats 1. Case B - level on all three keys Team 3 beat team 1 by 1-0; team 2 beat team 4 by 1-0 (winners each: 3 points, GD +1, GF 1). Order: 002 (-3501001), 003 (-3501001), 001, 004 Decided by the fallback: equal scores are ordered by member string, ascending because the table is read with ZRANGE. 002 comes before 003. This is arbitrary, not a football rule - real tables use head-to-head or other criteria, which this course does not implement. Case C - level on points, different goal difference Team 1 won 3-0 (GD +3); team 2 won 2-0 (GD +2); both against team 3. Order: 001 (-3503003), 002 (-3502002), 004, 003 Decided by goal difference. Team 3 is last: it lost 0-3 and 0-2 (GD -5), below team 4, which had not played. WHY THIS WORKS AS AN ANSWER ---------------------------- Each ordering comes from a real run, and each is attributed to the specific part of the composite score that separated the teams. The full tie is reported honestly as an arbitrary fallback rather than dressed up as a rule.