Changeset 9577c79 for docs/P2-RelationalDesign/RelationalDesignAIUsage.md
- Timestamp:
- 09/16/26 23:37:15 (13 days ago)
- Branches:
- main
- Children:
- 8b447ef
- Parents:
- df05838
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/P2-RelationalDesign/RelationalDesignAIUsage.md
rdf05838 r9577c79 69 69 > against the faculty database. No AI involvement is possible there — it needs a 70 70 > live connection to your assigned database. 71 72 ### Session 3 — 2026-09-16 73 74 Driven by the same design review logged in full in 75 [ERModelAIUsage](../P1-ConceptualModel/ERModelAIUsage.md#session-3--2026-09-16): 76 a sell order had nothing to check `holdings.quantity` against except itself, 77 so nothing stopped two sell orders from being granted the same units. 78 79 Changes to the P2 artefacts: 80 81 - `holdings` gained `reserved_quantity numeric(20,4) NOT NULL DEFAULT 0 82 CHECK (reserved_quantity >= 0 AND reserved_quantity <= quantity)` in 83 `schema_creation.sql`. 84 - `v_portfolio` gained `reserved_quantity` and the derived 85 `available_quantity = quantity - reserved_quantity`. 86 - [RelationalDesign](RelationalDesign.md) gained a "Reservation and the order 87 lifecycle" section explaining why the check is enforced at the database 88 level rather than trusted to application code, and why it does not conflict 89 with the existing `SELECT … FOR UPDATE` locking on the sell path. 90 - `data_load.sql` needed no change — `reserved_quantity` defaults to 0, which 91 is correct for every seeded holding. 92 93 Re-run end to end against the live database on `localhost:5433` 94 (`-init` then `-load-data`), and against a manually seeded 2 BTC holding to 95 reproduce the exact scenario that motivated the change — see 96 [UseCase0005Implementation](../P4-Prototype/UseCase0005Implementation.md) for 97 the transcript. 98 99 **What I decided:** to add the `CHECK` constraint rather than rely on 100 `trade.go` alone to keep the reservation consistent — the same reasoning 101 already applied to `avg_price NOT NULL` in session 2.
Note:
See TracChangeset
for help on using the changeset viewer.
