Tools

Model studio

Draw a data model at three levels, change it, and generate the tables for PostgreSQL, Spark SQL with Delta Lake and T-SQL; then run the PostgreSQL version on the estate's data, in your browser.

Estate
Level
Physical dialect

Physical: the same model as one database's columns and types; switch the dialect to compare.

Edit claims

A loss reported against one policy.

New attribute
Type
Attribute to drop
References
New entity (table name)
Information domain

The generated tables

Checked in CI by Spark 4.0.1's own SQL parser, then run on Delta Lake 4.0.1.

CREATE SCHEMA IF NOT EXISTS silver;

CREATE TABLE IF NOT EXISTS silver.regions (
    region_id BIGINT NOT NULL COMMENT 'Surrogate key',
    country STRING NOT NULL COMMENT 'NL, PL or DE',
    name STRING NOT NULL
)
USING DELTA
COMMENT 'A region of one of the three countries Harbour Mutual sells in. Key: region_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-party');

CREATE TABLE IF NOT EXISTS silver.products (
    product_id BIGINT NOT NULL COMMENT 'Surrogate key',
    line STRING NOT NULL COMMENT 'motor, home or travel: the line of business',
    name STRING NOT NULL,
    launched_on DATE NOT NULL
)
USING DELTA
COMMENT 'Something Harbour Mutual sells, in one line of business. Key: product_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-product');

CREATE TABLE IF NOT EXISTS silver.coverage_types (
    coverage_id BIGINT NOT NULL COMMENT 'Surrogate key',
    product_id BIGINT NOT NULL COMMENT 'references ent-product',
    name STRING NOT NULL COMMENT 'what is covered: third party, own damage, theft, flood',
    default_limit DECIMAL(12,2) NOT NULL COMMENT 'the most the insurer pays under this coverage, unless the policy says otherwise'
)
USING DELTA
COMMENT 'What a product can cover, with its default limit. Key: coverage_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-product');

CREATE TABLE IF NOT EXISTS silver.brokers (
    broker_id BIGINT NOT NULL COMMENT 'Surrogate key',
    region_id BIGINT NOT NULL COMMENT 'references ent-region',
    name STRING NOT NULL,
    commission_rate DECIMAL(4,3) NOT NULL COMMENT 'share of the premium paid to the broker, e.g. 0.125'
)
USING DELTA
COMMENT 'An intermediary who sells Harbour Mutual\'s policies for a commission. Key: broker_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-party');

CREATE TABLE IF NOT EXISTS silver.customers (
    customer_id BIGINT NOT NULL COMMENT 'Surrogate key',
    region_id BIGINT NOT NULL COMMENT 'references ent-region',
    name STRING NOT NULL,
    birth_date DATE NOT NULL,
    customer_since DATE NOT NULL,
    email STRING COMMENT 'contact address; not every customer gave one'
)
USING DELTA
COMMENT 'A person who holds, or has held, a Harbour Mutual policy. Key: customer_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-party');

CREATE TABLE IF NOT EXISTS silver.policies (
    policy_id BIGINT NOT NULL COMMENT 'Surrogate key',
    policy_number STRING NOT NULL COMMENT 'one per annual term, e.g. HM-MC-004211-2024',
    customer_id BIGINT NOT NULL COMMENT 'references ent-customer',
    product_id BIGINT NOT NULL COMMENT 'references ent-product',
    broker_id BIGINT COMMENT 'null: sold directly; references ent-broker',
    start_date DATE NOT NULL,
    end_date DATE NOT NULL COMMENT 'the last day of cover',
    status STRING NOT NULL COMMENT 'active, expired, lapsed (premium not paid) or cancelled',
    annual_premium DECIMAL(10,2) NOT NULL
)
USING DELTA
COMMENT 'One annual term of cover for one customer and one product. Key: policy_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-policy');

CREATE TABLE IF NOT EXISTS silver.policy_coverages (
    policy_id BIGINT NOT NULL COMMENT 'references ent-policy',
    coverage_id BIGINT NOT NULL COMMENT 'references ent-coverage-type',
    limit_amount DECIMAL(12,2) NOT NULL,
    deductible DECIMAL(10,2) NOT NULL COMMENT 'the part of each claim the customer pays (the excess)'
)
USING DELTA
COMMENT 'A coverage a policy includes, with its own limit and deductible. Key: policy_id, coverage_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-policy');

CREATE TABLE IF NOT EXISTS silver.premium_transactions (
    transaction_id BIGINT NOT NULL COMMENT 'Surrogate key',
    policy_id BIGINT NOT NULL COMMENT 'references ent-policy',
    due_date DATE NOT NULL,
    amount DECIMAL(10,2) NOT NULL,
    paid_on DATE COMMENT 'null: not paid'
)
USING DELTA
COMMENT 'A premium instalment due on a policy, and whether it was paid. Key: transaction_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-finance');

CREATE TABLE IF NOT EXISTS silver.claims (
    claim_id BIGINT NOT NULL COMMENT 'Surrogate key',
    claim_number STRING NOT NULL,
    policy_id BIGINT NOT NULL COMMENT 'references ent-policy',
    loss_date DATE NOT NULL COMMENT 'when the event happened',
    reported_date DATE NOT NULL COMMENT 'when Harbour Mutual heard of it',
    cause STRING NOT NULL,
    status STRING NOT NULL COMMENT 'open, closed or rejected',
    reserve DECIMAL(12,2) NOT NULL COMMENT 'what the insurer still expects to pay on an open claim'
)
USING DELTA
COMMENT 'A loss reported against one policy. Key: claim_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-claim');

CREATE TABLE IF NOT EXISTS silver.claim_payments (
    payment_id BIGINT NOT NULL COMMENT 'Surrogate key',
    claim_id BIGINT NOT NULL COMMENT 'references ent-claim',
    paid_on DATE NOT NULL,
    amount DECIMAL(12,2) NOT NULL
)
USING DELTA
COMMENT 'A payment made on a claim. Key: payment_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-claim');

CREATE TABLE IF NOT EXISTS silver.claim_documents (
    document_id STRING NOT NULL COMMENT 'Surrogate key, generated',
    claim_id BIGINT NOT NULL COMMENT 'references ent-claim',
    doc STRING NOT NULL COMMENT 'adjuster notes, damaged items, fraud flags'
)
USING DELTA
COMMENT 'An adjuster\'s document on a claim, as JSON. Key: document_id.'
TBLPROPERTIES ('quality' = 'silver', 'domain' = 'dom-claim');

Run it on the data

PostgreSQL starts in this browser when you press Run.

Rows loaded, against the seed
TablePGliteSeedSame

Try this

0 of 4 done

Switch the level between conceptual, logical and physical with the claims entity selected.

Look for: The boxes stay; what they say changes: names and relationships, then keys and attributes, then each database's own types.

Add a fraud_score attribute (decimal, optional) to claims, then look at the PostgreSQL, Spark SQL and T-SQL tabs.

Look for: One change in the logical model appears in all three dialects, each with its own type.

Press Run in the browser.

Look for: PostgreSQL starts in your browser, creates every table and loads Harbour Mutual's rows; a new column is there and empty.

Switch the estate to Kestrel and compare its claims table with Harbour Mutual's.

Look for: Kestrel keeps reserves in cents and does not enforce the link from a claim to its policy: the merger's first conflicts.

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.