Tools

Contract editor

The Claims product's data contract: what its table promises the teams that read it. Change the schema, the meaning, the quality promises, the service levels, the owner and the version; the draft is validated against the Open Data Contract Standard and every change is classified as additive or breaking.

Exercise: Add a column without breaking anyone

The fraud team wants a fraud_score on every claim, a decimal number, empty for claims scored before the model existed. Add it to the Claims contract with a description that says what it means, change nothing a consumer relies on, and give the draft the version its change needs.

  • The draft has an optional decimal column fraud_score.
  • fraud_score has a description of what it means, not just its name.
  • No change breaks a consumer.
  • The version is a new minor version of 1: higher than 1.0.0, still 1.x.
Back to chapter 24
Version
Published: 1.0.0
Status
Owner
Freshness (hours)
Retention (years)
valid
against ODCS v3.1.0
0
changes from version 1.0.0
0
breaking
ok
no change: the version can stay

Schema and meaning

The table claims: one row per column the contract promises
ColumnTypeRequiredUnique ClassificationMeaningRemove
claim_id · key Surrogate key
claim_number claim_number
policy_id policy_id
loss_date when the event happened
reported_date when Harbour Mutual heard of it
cause cause
status open, closed or rejected
reserve what the insurer still expects to pay on an open claim
New column
lower case, digits and _
Type

Quality promises

Each promise is one of the model's quality rules, with the share of rows that must pass it
RuleDimensionColumnAt least (%)Withdraw
A claim is reported on or after its loss dateValidityreported_date
A claim has a reported dateCompletenessreported_date
A claim's cause is on the loss-cause listValiditycause
A reserve is between 0 and the large-loss limit of 100,000Accuracyreserve
A claim is reported within 60 days of the lossTimelinessloss_date
Each claim number is used onceUniquenessclaim_number
A claim's policy existsConsistencypolicy_id

The change, checked

The draft is valid against the Open Data Contract Standard v3.1.0 schema.

No change from the published version.

The draft as an Open Data Contract Standard document
{
  "apiVersion": "v3.1.0",
  "kind": "DataContract",
  "id": "dc-claims",
  "name": "Claim: claims",
  "version": "1.0.0",
  "status": "active",
  "domain": "Claim",
  "dataProduct": "Claim",
  "description": {
    "purpose": "A loss reported against one policy.",
    "usage": "Read by reporting, reserving and the claims assistant through the product's output port."
  },
  "team": {
    "name": "Claim domain",
    "members": [
      {
        "username": "ruud.hendriks@harbourmutual.example",
        "name": "Ruud Hendriks",
        "role": "owner",
        "description": "Claims Director"
      }
    ]
  },
  "schema": [
    {
      "name": "claims",
      "physicalName": "claims",
      "physicalType": "table",
      "logicalType": "object",
      "description": "A loss reported against one policy.",
      "properties": [
        {
          "name": "claim_id",
          "logicalType": "integer",
          "physicalType": "integer",
          "required": true,
          "unique": true,
          "primaryKey": true,
          "primaryKeyPosition": 1,
          "classification": "internal",
          "description": "Surrogate key"
        },
        {
          "name": "claim_number",
          "logicalType": "string",
          "physicalType": "text",
          "required": true,
          "unique": false,
          "classification": "internal",
          "description": "claim_number"
        },
        {
          "name": "policy_id",
          "logicalType": "integer",
          "physicalType": "integer",
          "required": true,
          "unique": false,
          "classification": "internal",
          "description": "policy_id"
        },
        {
          "name": "loss_date",
          "logicalType": "date",
          "physicalType": "date",
          "required": true,
          "unique": false,
          "classification": "internal",
          "description": "when the event happened"
        },
        {
          "name": "reported_date",
          "logicalType": "date",
          "physicalType": "date",
          "required": true,
          "unique": false,
          "classification": "internal",
          "description": "when Harbour Mutual heard of it"
        },
        {
          "name": "cause",
          "logicalType": "string",
          "physicalType": "text",
          "required": true,
          "unique": false,
          "classification": "confidential",
          "description": "cause"
        },
        {
          "name": "status",
          "logicalType": "string",
          "physicalType": "text",
          "required": true,
          "unique": false,
          "classification": "internal",
          "description": "open, closed or rejected"
        },
        {
          "name": "reserve",
          "logicalType": "number",
          "physicalType": "numeric(12,2)",
          "required": true,
          "unique": false,
          "classification": "confidential",
          "description": "what the insurer still expects to pay on an open claim"
        }
      ],
      "quality": [
        {
          "id": "rule-reported-after-loss",
          "name": "A claim is reported on or after its loss date",
          "dimension": "conformity",
          "type": "sql",
          "query": "SELECT 100.0 * AVG(CASE WHEN COALESCE(reported_date >= loss_date, FALSE) THEN 1 ELSE 0 END) FROM claims",
          "mustBeGreaterOrEqualTo": 98,
          "unit": "percent",
          "severity": "warning"
        },
        {
          "id": "rule-claim-reported-present",
          "name": "A claim has a reported date",
          "dimension": "completeness",
          "type": "sql",
          "query": "SELECT 100.0 * AVG(CASE WHEN COALESCE(reported_date IS NOT NULL, FALSE) THEN 1 ELSE 0 END) FROM claims",
          "mustBeGreaterOrEqualTo": 99,
          "unit": "percent",
          "severity": "warning"
        },
        {
          "id": "rule-claim-cause-known",
          "name": "A claim's cause is on the loss-cause list",
          "dimension": "conformity",
          "type": "sql",
          "query": "SELECT 100.0 * AVG(CASE WHEN COALESCE(cause IN ('collision', 'theft', 'windscreen', 'storm', 'escape of water', 'fire', 'medical', 'baggage'), FALSE) THEN 1 ELSE 0 END) FROM claims",
          "mustBeGreaterOrEqualTo": 99,
          "unit": "percent",
          "severity": "warning"
        },
        {
          "id": "rule-claim-reserve-range",
          "name": "A reserve is between 0 and the large-loss limit of 100,000",
          "dimension": "accuracy",
          "type": "sql",
          "query": "SELECT 100.0 * AVG(CASE WHEN COALESCE(reserve BETWEEN 0 AND 100000, FALSE) THEN 1 ELSE 0 END) FROM claims",
          "mustBeGreaterOrEqualTo": 99,
          "unit": "percent",
          "severity": "warning"
        },
        {
          "id": "rule-claim-reported-on-time",
          "name": "A claim is reported within 60 days of the loss",
          "dimension": "timeliness",
          "type": "sql",
          "query": "SELECT 100.0 * AVG(CASE WHEN COALESCE(reported_date - loss_date <= 60, FALSE) THEN 1 ELSE 0 END) FROM claims",
          "mustBeGreaterOrEqualTo": 95,
          "unit": "percent",
          "severity": "warning"
        },
        {
          "id": "rule-claim-number-unique",
          "name": "Each claim number is used once",
          "dimension": "uniqueness",
          "type": "sql",
          "query": "SELECT 100.0 * AVG(CASE WHEN COALESCE(NOT EXISTS (SELECT 1 FROM claims o WHERE o.claim_number = claims.claim_number AND o.claim_id <> claims.claim_id), FALSE) THEN 1 ELSE 0 END) FROM claims",
          "mustBeGreaterOrEqualTo": 100,
          "unit": "percent",
          "severity": "error"
        },
        {
          "id": "rule-claim-policy-exists",
          "name": "A claim's policy exists",
          "dimension": "consistency",
          "type": "sql",
          "query": "SELECT 100.0 * AVG(CASE WHEN COALESCE(EXISTS (SELECT 1 FROM policies r WHERE r.policy_id = claims.policy_id), FALSE) THEN 1 ELSE 0 END) FROM claims",
          "mustBeGreaterOrEqualTo": 100,
          "unit": "percent",
          "severity": "error"
        }
      ]
    }
  ],
  "slaProperties": [
    {
      "property": "freshness",
      "value": 24,
      "unit": "h"
    },
    {
      "property": "retention",
      "value": 7,
      "unit": "y"
    }
  ]
}

Try this

0 of 4 done

Add an optional column fraud_score of type numeric(12,2).

Look for: The change is additive: publishing it needs version 1.1.0, and no consumer breaks.

Remove the reserve column.

Look for: Breaking: the systems that read reserve are listed, and only a new major version, 2.0.0, may carry the change.

Lower the reserve rule's threshold to 90%, or let the data be 48 hours old.

Look for: A weaker promise breaks consumers who relied on it, with no change to the schema at all.

Break nothing, then download the contract as ODCS.

Look for: The file passes the Open Data Contract Standard's own schema, here and in CI.

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Cloud Data Architecture Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.