The Flyweight of the Normalized Dictionary
Conserving relational space through normalized lookup tables.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Transmutation // Essence Compression
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SQL PATTERN //
-- The Flyweight Table (Intrinsic State)
CREATE TABLE spell_elements (
element_id SERIAL PRIMARY KEY,
element_name VARCHAR(50) UNIQUE NOT NULL,
base_color_hex CHAR(7) NOT NULL
);
-- The Heavy Entity (Extrinsic State)
CREATE TABLE cast_spells (
cast_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
mage_id INT NOT NULL,
element_id INT REFERENCES spell_elements(element_id),
power_output NUMERIC NOT NULL,
cast_location GEOMETRY(Point, 4326)
);
The Flyweight of the Normalized Dictionary
In massive data matrices, storing the text ‘PYROMANCY’ and its hex color #FF4500 a billion times leads to massive aether-bloat. The Flyweight pattern is essentially the fundamental doctrine of Database Normalization.
By shifting the intrinsic, repeating state (the spell element and its color) into a dictionary table (spell_elements), and replacing the heavy text strings with lightweight integer keys (element_id), we drastically reduce the storage footprint and accelerate query scans.
Runic Tags:
#normalization
#flyweight
#structural