What is a Canonical Model?
Canonical Flat Table (The Denormalized Summary)
To solve the slow multi-table JOIN performance issue, we combine your normalized tables into a single canonical summary table (canonical_policy_summary):
Instead of letting multiple tables or systems use separate formats, a canonical model standardizes fields and relationships into one common layout.
SEPERATE TABLES INTO SINGLE TABLE
customer (customer_id (PK), first_name, last_name, date_of_birth, gender, email, phone_number, address, created_at)
agent (agent_id (PK), first_name, last_name, agency_name, license_number, email, phone_number)
policy (policy_id (PK), customer_id (FK), agent_id (FK), product_type, sum_assured, premium_amount, payment_frequency, status, start_date, end_date)
transaction (transaction_id (PK), policy_id (FK), transaction_type, amount, transaction_date, status)
payment (payment_id (PK), transaction_id (FK), policy_id (FK), amount_paid, payment_method, gateway_reference_id, payment_date)
claim (claim_id (PK), policy_id (FK), claim_type, incident_date, claim_amount, status, settlement_date
CANONICAL MODEL FOR POLICY
How to Populate It (Daily Job)
Once a day, a scheduled job runs this query to refresh the canonical model so apps don't have to run live joins:
Why This Works
Eliminates Live Joins: Dashboards and searches query canonical_policy_summary directly in milliseconds.
Standardized Layout: Customer names, agent details, and financial totals live together in one predictable structure.
No comments:
Post a Comment