Structured Data
Study guides: DISC-DA, ACIA-M2, Exam ACIA-CAPSTONE
Structured Data are data organized under a fixed schema: records arranged as rows, each with the same set of named fields arranged as columns, and each field holding values of one declared data type. Because every record has the same shape, structured data are stored in the tables of a relational database and can be filtered, sorted, joined and summarized directly with SQL.
A table of structured data has three parts:
- A schema. It fixes, before any data are loaded, each table's fields, their data types (integer, decimal, text, date), and constraints such as a field that may not be null or must be unique.
- Records that fit it. A record that does not fit, such as a date with 30 February in it, is rejected or flagged when loaded. This is a large part of why structured data are easier to trust than unstructured data.
- Keys. A primary key identifies each record, such as the policy number, and foreign keys link a record to records in other tables, such as the policy number on a claim. Keys make a join possible and let duplicates be found.
Data are structured, semi-structured or unstructured according to their shape:
| Kind | Shape | Insurance example |
|---|---|---|
| Structured | A fixed set of typed fields in every record | Policy, premium, billing and claim tables |
| Semi-structured | Labels on the pieces, but no single fixed table shape | JSON or XML telematics records |
| Unstructured | No predefined fields | Adjusters' notes, photos, recorded calls |
Most insurer policy, premium and claim data are structured. So are the records reported to a statistical plan, external data such as credit attributes or motor vehicle records delivered in fixed layouts, and the aggregated tables in a data warehouse or data mart.
An underwriter types inspection notes into a free-text field of the policy database. Are the notes structured data?
- The notes sit in a database column, but each one is free text with no fixed fields inside it.
- Whether data are structured depends on their shape, not on where they are stored.
- The notes are unstructured data. Moving them to a data mart would not change that.
Deciding by storage instead of shape A spreadsheet with consistent columns is structured even though it is not in a database, and a database field holding free-text notes holds unstructured data. Decide by whether each record follows a fixed set of typed fields.
Summarizing structured data with SQL
A summary query selects the fields it needs, filters rows with WHERE, groups them with GROUP BY, aggregates each group with functions such as COUNT, SUM, AVG, MIN and MAX, and filters the groups with HAVING. WHERE filters rows before they are grouped. HAVING filters groups after aggregation, so a condition on a total, such as territories with more than 1,000 car-years, belongs in HAVING. The result is itself a structured table, one row per group.
Let row i of a table have a grouping field x_i, such as territory, a measure y_i, such as premium, and an exposure e_i. The total of the measure over the rows in group g, which SUM(y) ... GROUP BY x returns, is
S_g = \sum_{i \,:\, x_i = g} y_i
The group's average per unit of exposure, such as the average premium per car-year, is
\bar{y}_g = \frac{\sum_{i \,:\, x_i = g} y_i}{\sum_{i \,:\, x_i = g} e_i}
What does this query return for the policy table? A personal auto policy table holds eight policies.
policy terr exposure premium P1 T1 1.00 900 P2 T1 0.50 450 P3 T1 1.00 1,000 P4 T2 1.00 1,300 P5 T2 1.00 1,200 P6 T3 0.25 400 P7 T3 1.00 1,500 P8 T3 0.75 1,100 SELECT terr, COUNT(*) AS policies, SUM(exposure) AS expo, SUM(premium) AS prem, SUM(premium) / SUM(exposure) AS avg_prem FROM policy GROUP BY terrAnswer
- Each group's sums run over its own rows.
- For territory 1, the premium is
900 + 450 + 1{,}000 = 2{,}350over2.50car-years, soavg_premis940.- The other territories follow in the same way.
terr policies expo prem avg_prem T1 3 2.50 2,350 940 T2 2 2.00 2,500 1,250 T3 3 2.00 3,000 1,500
- Territory 3 has as many policies as territory 1 but less exposure, because two of its policies were in force for part of the year.
- Counting policies would overstate its size, which is why the summary divides premium by exposure.
From other kinds of data to structured data
Unstructured Data and semi-structured data become structured once features are extracted or the records are flattened into rows. That is usually how they enter a model as predictors.
Limits of a fixed schema
A fixed schema captures only what its designers anticipated. A fact with no field, such as the reason a claim was reopened, is either lost or typed into a free-text field, where it becomes unstructured again.