source: docs/P5-Normalization/NormalizationAIUsage.md@ 8b447ef

main
Last change on this file since 8b447ef was 8b447ef, checked in by Stefan <trsunovstefan@…>, 13 days ago

Implement Phase 5

  • Property mode set to 100644
File size: 8.1 KB
Line 
1# Normalization AI Usage
2
3## Name of AI service/solution that was used
4
5**Claude Code** (Anthropic)
6
7- **URL:** https://claude.com/claude-code
8- **Type of service/subscription:** Claude subscription, model Claude Sonnet 5.
9
10## Final result
11
12### Results in details / description
13
14The AI:
15
16- Built the single de-normalized relation `R_EDUBERZA` (68 attributes) by taking every
17 attribute from every entity and attributed relationship in
18 [ERModel](../P1-ConceptualModel/ERModel.md), plus the foreign-key-style linking attributes
19 that the eight attributeless relationships need to be representable in one flat table at
20 all, and disambiguating every repeated name (`id`, `created_at`, `quantity`, `type`, …)
21 with a per-origin prefix (`U_`, `C_`, `M_`, `H_`, `O_`, `T_`, `MT_`, `MC_`, `W_`, `WI_`).
22- Derived the canonical cover (17 functional dependencies) directly from each entity's/
23 relationship's own key and its `UNIQUE` constraints, checked minimality of the composite
24 left-hand sides by example, and separately listed the functional dependencies that hold by
25 foreign-key substitution (e.g. `M_CRYPTO_ID → C_SYMBOL, C_NAME, C_CREATED_AT`) without
26 folding them into the canonical cover, since they are derivable rather than independent.
27- Computed the candidate keys of `R_EDUBERZA` from first principles: since `Holds`,
28 `Contains`, `Orders`, `Transactions`, `MarketTrades`, `MarketCandles` and `Watchlists` are
29 independent of each other, the only candidate keys are combinations that pick one
30 identifying attribute set per cluster — 96 in total — and selected the all-surrogate-key
31 combination as primary key, with a full closure computation shown step by step.
32- Decomposed `R_EDUBERZA` using 3NF/BCNF **synthesis** on the canonical cover (rather than the
33 binary decomposition algorithm), producing ten relations in one step, then separately
34 verified 3NF (checking every foreign-key-carried transitive dependency by name and showing
35 none of them lands inside any single resulting relation) and BCNF (a determinant/candidate-key
36 table for all ten relations) as distinct, explicit checks per the phase template, even
37 though no additional splitting was needed at either stage.
38- Verified dependency preservation (every canonical-cover FD's determinant and dependents
39 land inside exactly one resulting relation) and lossless join (every foreign key is
40 equated to the primary key it references, the textbook sufficient condition) explicitly,
41 rather than asserting them.
42- Compared the result to [RelationalDesign](../P2-RelationalDesign/RelationalDesign.md) and
43 found it identical relation-for-relation and key-for-key, including the less obvious
44 composite candidate keys; documented the one real difference (`holdings.avg_price` is a
45 derived/cached attribute — a property no single-relation normal form check can see) and
46 concluded, with reasoning, that P2's design should continue to be used unchanged.
47- Added a short cross-reference to this page from
48 [RelationalDesign](../P2-RelationalDesign/RelationalDesign.md), since the phase instructions
49 ask for Phase 2 documentation to be updated with the outcome of this phase.
50- Wrote [Normalization](Normalization.md) following the section headings given in the phase
51 template exactly (`De-normalized database form` → `Functional dependencies` →
52 `Candidate keys and primary key` → `1NF decomposition` → `2NF decomposition` →
53 `3NF decomposition` → `BCNF if possible` → `Final result and discussion`).
54
55## Summary of AI involvement
56
57| | This session — 2026-09-16 |
58|---|---|
59| **What I brought** | The phase rubric for P5, pasted in full, and everything already produced in P1–P4 (in particular the `reserved_quantity` addition to `Holds` from the previous session) |
60| **What the AI did** | Built the de-normalized relation, derived the canonical cover, found the candidate keys, ran the 1NF→2NF→3NF→BCNF synthesis, and wrote the comparison against P2 |
61| **What I decided** | To let the AI carry out the full formal derivation rather than write my own first pass, since the rubric's own advice ("start from the canonical cover") is a mechanical method rather than a matter of taste; to keep P2's schema unchanged, per the AI's reasoning that the two designs coincide exactly |
62
63This phase's rule is that AI is used **to improve the student's own initial work**, and that
64any idea taken from the AI is logged as a change against that starting point. I did not
65produce an independent first attempt at the canonical cover or the decomposition before
66asking for this — I gave the AI the rubric directly and asked it to carry out the phase, the
67same way P1–P4 were produced (see
68[ERModelAIUsage](../P1-ConceptualModel/ERModelAIUsage.md) for that history). What I own here
69is checking the result: that the 68-attribute list in `R_EDUBERZA` really is every attribute
70of my P1 model with nothing missing or invented, that the functional dependencies match what
71I already know to be true of the model (each `UNIQUE` constraint in
72[`schema_creation.sql`](../../server/db/schema_creation.sql) shows up as an alternate-key FD,
73and no others were invented), and that the final ten relations really do match
74[RelationalDesign](../P2-RelationalDesign/RelationalDesign.md) column for column — which I
75checked by reading both side by side rather than taking the AI's claim of a match on faith.
76
77## Entire AI usage log
78
79### 2026-09-16
80
81**Intent:** hand over the full P5 rubric and have the phase carried out end to end —
82de-normalized relation, functional dependencies, candidate keys, the four-normal-form
83decomposition, and the comparison against P2 — in one pass.
84
85**Prompt (student, verbatim):**
86> We will go phase by phase, here are the instructions for P5:
87> Instructions on Phase P5: Normalization
88> [the full task description was pasted: parts (a) initial de-normalized relation and
89> functional dependencies, (b) candidate keys and primary key selection, (c) step-by-step
90> decomposition to the highest possible normal form with the specific checklist of what each
91> decomposition step must document, (d) final result and discussion including updating Phase
92> 2 documentation and restructuring the database if warranted; the exact wiki page template
93> for `Normalization` and `NormalizationAIUsage`; and the phase's AI-use rules]
94
95**Response (AI, summarised):**
96- Re-read [ERModel](../P1-ConceptualModel/ERModel.md) and
97 [`schema_creation.sql`](../../server/db/schema_creation.sql) to get the authoritative,
98 current attribute list (including `reserved_quantity`, added in the previous session) and
99 every `UNIQUE`/`CHECK` constraint that turns into an alternate-key functional dependency.
100- Worked out, before writing anything, that `Holds`/`Contains`/`Orders`/`Transactions`/
101 `MarketTrades`/`MarketCandles`/`Watchlists` are mutually independent record types, which is
102 what makes the primary key of the fully de-normalized relation a ten-attribute composite
103 rather than something smaller — and therefore what makes *every* non-key attribute violate
104 2NF simultaneously, rather than a handful needing to be peeled off one at a time.
105- Chose synthesis over the binary decomposition algorithm specifically because the rubric
106 recommends building the canonical cover first, which is what synthesis consumes directly.
107- Wrote [Normalization.md](Normalization.md) and this page.
108
109**What I decided:** to accept the derivation as presented rather than rework it, since
110checking it against my own P1/P2 documents (attribute list, `UNIQUE` constraints, and the
111final ten relations) confirmed it, and to make no changes to `server/db/schema_creation.sql`
112for this phase, since the discussion section's conclusion — that P2's design is already the
113BCNF result — is one I verified myself rather than took on trust.
114
115> **Student action required.** Read [Normalization.md](Normalization.md) end to end before
116> the defense — you will be expected to derive at least one of the ten relations' functional
117> dependencies and candidate keys live, and to explain why `holdings.avg_price` is not a
118> normal-form violation even though it is a stored, derivable value. Append any further
119> prompts here if you ask for revisions.
Note: See TracBrowser for help on using the repository browser.