6. Logical models
A logical model adds what a database needs to know, still without choosing one: every attribute and its type, the keys that identify each row, the cardinality of every relationship, and no redundancy.
The clip starts from three conceptual boxes, Party, Policy and Claim. Each gains its attributes with a primary key, and Policy and Claim gain foreign keys; the relationships gain their cardinality, one to many. Then two redundancies in the policy are lit: three numbered driver columns, a repeating group, and a copy of the holder's name. They are removed: the drivers become rows of a policy_driver table between policy and party. Last, the three normal forms in one sentence each.
The idea: the conceptual model, made precise
The logical model keeps the conceptual model's entities and relationships and makes each one precise enough to build. Four things are added:
- Attributes, each with a logical type (text, date, decimal, code) and whether it is required. Logical types are not yet a database's types; chapter 7 turns them into PostgreSQL, Spark or T-SQL.
- Keys. A primary key identifies each row: one policy, one
policy_id. A foreign key refers to another entity's key: the claim'spolicy_idsays which policy it is against. - Cardinality: how many on each side. One policy has many claims; each claim is against exactly one policy. A many-to-many relationship (a policy has several drivers, and a driver is on several policies) becomes an entity of its own between the two, an associative entity.
- Normalisation: each fact stored in one place, so it can never disagree with a copy of itself.
Normalisation is usually taught as normal forms, and three are enough for nearly all work. First normal form: one value per cell and no repeating groups (no driver1_name, driver2_name, driver3_name). Second: every attribute depends on the whole key, not on part of it. Third: every attribute depends on nothing but the key (a claim holds its policy's id, not a copy of the policyholder's name).
A worked example: Harbour Mutual's logical model
Harbour Mutual's logical model has 11 entities and 12 foreign keys. Every entity has a primary key, and the number of keys made of two attributes is 1. policy_coverages, keyed by policy_id and coverage_id, is one of them: the associative entity between policies and the types of cover they include.
Kestrel's model is less careful, as the Model studio shows: its claims table keeps reserves in cents and does not declare its link to the policy as a foreign key. A logical model makes gaps like these visible before they become the merger's problem.
Why it matters for Alex
The logical model is the contract between Alex and the builders: whichever platform chapter 28 chooses, the entities, keys and rules carry over. It is also where Alex can prove that a model answers the business's questions before a single pipeline is written. If "which drivers are on this policy?" needs a join the model does not have, it is far cheaper to find out now.
Where it goes wrong
- Skipping it. Going from boxes straight to tables bakes one database's habits into the model, and the next platform inherits them.
- Denormalising too early. Copies "for performance" in the logical model are copies nobody can reconcile later.
- Keys from the source system. A policy number that changes format after a migration makes a poor primary key. Use a surrogate key, and keep the number as an attribute.
- Undeclared relationships. A foreign key that exists only in someone's head, as in Kestrel's claims, lets orphan claims in.
Exercises
The lab checks each one against facts written down in advance, so any answer the brief allows passes. A pass is kept in this browser.
Remove the repeating group
A policy can have any number of named drivers, and a driver can be named on several policies. Each driver is a party, with the name stored once.
The lab checks that:
- No repeating group: no numbered driver columns.
- A table between policies and parties records each driver on each policy.
- A driver's name is stored only on the party.
Remove the copies
A claim is against a policy, and a policy is held by a customer. The customer's name and email belong to the customer, not to each claim.
The lab checks that:
- Claims hold no copy of the customer: the customer is reached through the policy.
- Each claim still reaches its customer through its policy.
- The customer's name and email live on customers.
Read the cardinality
Open Harbour Mutual's model in the Model studio at the logical level. For each pair of tables, choose the cardinality from the first to the second.
claims to policies
policies to claims
policies to coverage_types
claim_payments to claims
customers to policies
On Azure
Azure's databases hold the logical model with different strictness, which matters when you choose one:
- Azure SQL Database enforces primary and foreign keys: an orphan claim is refused.
- The Microsoft Fabric warehouse lets you declare primary and foreign keys only as NOT ENFORCED: they document the model and help the query optimiser, and your pipelines must keep them true.
- Delta tables, on Fabric or Azure Databricks, enforce NOT NULL and CHECK constraints. On Databricks, primary and foreign keys can be declared in Unity Catalog as informational constraints, which are not enforced.
- Power BI and Fabric semantic models show each relationship with its cardinality (one to many, many to many) in the model view: the logical model's cardinality again, for reporting.
Whatever enforces it, keep the logical model as the source of truth, and let the physical design say which rules the database checks and which the pipeline must (chapter 7).
Take it to work
Logical model checklist
Before anything is built, check each entity against this list.
Every entity
- Has a primary key, and a sentence saying what one row is
- Every attribute has a type and says whether it is required
Every relationship
- Has its cardinality on both sides
- Every many-to-many relationship has an associative entity
Normal forms
- No repeating groups, and no lists in one attribute
- No attribute that depends on only part of a key
- No copies of another entity's attributes
The questions
- Write down the five questions the business will ask. Can the model answer each one by following its keys?
Tools in this chapter
- Model studio · Draw conceptual, logical and physical models, generate DDL for PostgreSQL, Spark SQL and T-SQL, and run it on Harbour Mutual's data in your browser.
Terms taught here: Logical modelCardinalityPrimary keyForeign keyNormalisationNormal form