liveBook · Manning

Data model

As explained in Grokking Software Architecture

A representation of the data structures, attributes, and relationships that an application stores and manipulates.

A flexible scorecard system need not give every metric its own database column. Treat metrics such as Same Store Sales and Inventory Turnover as attributes with definitions and values, so new fields can be added without changing the schema. section 8.6.2

Dynamic rows are a tradeoff, not a universal fix: they can weaken type safety and slow queries that filter or aggregate attributes across many records. Use this pattern for dynamic configuration or variable metadata, not stable core entities such as Users or Orders. section 8.6.2

Listing 8.8 Dynamic Rows
-- 1. The Core Application (Universal)
CREATE TABLE LoanApplication (
    id INT PRIMARY KEY,
    business_name VARCHAR(255),
    scorecard_type_id INT -- Links to 'Retail', 'Mfg', etc.
);
 
-- 2. The Definitions (Metadata)
CREATE TABLE ScorecardAttributes ( #A
    id INT PRIMARY KEY,
    scorecard_type_id INT, -- e.g., 'Manufacturing'
    attribute_name VARCHAR(100), -- e.g., 'InventoryTurnover'
    weight DECIMAL -- How much is this worth?
);
 
-- 3. The Values (The actual data)
CREATE TABLE ApplicationValues (
    application_id INT,
    attribute_id INT,
    value DECIMAL
);

The schema separates applications, attribute definitions, and attribute values—the pieces that let scorecards vary without hardcoded columns. section 8.6.2

How Grokking Software Architecture covers it

How deep it goes
Compares hardcoded columns with dynamic rows, gives an Entity-Attribute-Value schema, and warns about type safety and query performance.
Examples
Uses scorecard metrics such as Same Store Sales, Inventory Turnover, and a Global Risk Factor.
What you can do after
Apply dynamic rows to add scorecard fields without schema changes, reserving the pattern for variable metadata.
How it connects
Connects data modeling to Entity-Attribute-Value, schema changes, type safety, and query performance.

Also explained in

Compare how 26 books explain data model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.