POC

Operational ↔ Analytical
Modeling Lab

One synthetic healthcare dataset. Two deliberately different models.

10 patients · 295 encounters · 2000 observations
AI available
01

Load the operational source

The FHIR snapshot is transformed into normalized relational entities with primary keys, foreign keys, constraints, and indexes. Nested arrays become child tables.

10patient
35organization
36location
35practitioner
295encounter
2000observation
216condition
806procedure
395claim
2004claim item
100medication request
Inspect normalized schema
Drag tables to rearrange the schema.
100%
Normalized operational modelclaimidpatient_idorganization_idlocation_idstatusclaim_typestart_atend_atcreated_attotal_amountcurrency395 rowsclaim_diagnosisclaim_idsequencecondition_id216 rowsclaim_itemclaim_idsequenceproduct_codeproduct_displaynet_amountcurrencyencounter_id2004 rowsconditionidpatient_idencounter_idclinical_statuscodecode_displayonset_atrecorded_at216 rowsencounteridpatient_idorganization_idlocation_idstatusclass_codetype_codetype_displaystart_atend_at295 rowsencounter_participantencounter_idpractitioner_idrole_code295 rowslocationidnameorganization_idcitystate36 rowsmedication_requestidpatient_idencounter_idpractitioner_idstatusmedication_codemedication_displayauthored_atdosage_text100 rowsobservationidpatient_idencounter_idstatuscategory_codecodecode_displayeffective_atvalueunit2000 rowsorganizationidnametype_code35 rowspatientidgiven_namefamily_namegenderbirth_datemarital_status10 rowspatient_addressidpatient_idlinecitystatepostal_codecountryis_current10 rowspractitioneridgiven_namefamily_namegender35 rowsprocedureidpatient_idencounter_idstatuscodecode_displaystart_atend_at806 rows
claim395 rows
  • id
  • patient_id
  • organization_id
  • location_id
  • status
  • claim_type
  • start_at
  • end_at
  • created_at
  • total_amount
  • currency
3-row preview
[{'id': 'cd1eb208-c940-1245-6016-f4b5381b2bd4', 'patient_id': 'cd1eb208-c940-1245-d459-caf6402bc11e', 'organization_id': '79508e39-d0b0-3613-9d54-168f6e1c3a18', 'location_id': '720b6888-9941-34d4-8fcb-91343d69d4f2', 'status': 'active', 'claim_type': 'professional', 'start_at': '1941-02-22T11:53:38-04:00', 'end_at': '1941-02-22T12:08:45-04:00', 'created_at': '1941-02-22T12:08:45-04:00', 'total_amount': 136.8, 'currency': 'USD'}, {'id': '757963e8-7ab5-8fb1-b256-d7aef8dfadd8', 'patient_id': '757963e8-7ab5-8fb1-170f-e8a18b9bed22', 'organization_id': '047f6113-bd42-353b-8368-cf2352868915', 'location_id': '681e6731-f711-3f93-8952-8ddcf1ffa78b', 'status': 'active', 'claim_type': 'professional', 'start_at': '2016-03-22T17:14:25-04:00', 'end_at': '2016-03-22T17:29:25-04:00', 'created_at': '2016-03-22T17:29:25-04:00', 'total_amount': 136.8, 'currency': 'USD'}, {'id': '0c18b66b-75ce-fdbf-636c-4708e6ead780', 'patient_id': '0c18b66b-75ce-fdbf-b2a3-45b9068e07f4', 'organization_id': 'c7542447-e06e-32cb-b6db-243c23a0dbc2', 'location_id': '903e1531-4e7b-3e59-9819-f42f3f75236a', 'status': 'active', 'claim_type': 'professional', 'start_at': '2000-12-08T06:04:00-05:00', 'end_at': '2000-12-08T06:19:00-05:00', 'created_at': '2000-12-08T06:19:00-05:00', 'total_amount': 85.55, 'currency': 'USD'}]
claim_diagnosis216 rows
  • claim_id
  • sequence
  • condition_id
3-row preview
[{'claim_id': 'cd1eb208-c940-1245-6016-f4b5381b2bd4', 'sequence': 1, 'condition_id': 'cd1eb208-c940-1245-64cd-6c008392f32f'}, {'claim_id': '757963e8-7ab5-8fb1-b256-d7aef8dfadd8', 'sequence': 1, 'condition_id': '757963e8-7ab5-8fb1-8c78-3e76a7690e0f'}, {'claim_id': '0a4c9694-1422-5288-6841-d58fa3a1513f', 'sequence': 1, 'condition_id': '0a4c9694-1422-5288-a6a7-b95179144369'}]
claim_item2004 rows
  • claim_id
  • sequence
  • product_code
  • product_display
  • net_amount
  • currency
  • encounter_id
3-row preview
[{'claim_id': 'cd1eb208-c940-1245-6016-f4b5381b2bd4', 'sequence': 1, 'product_code': '410620009', 'product_display': 'Well child visit (procedure)', 'net_amount': 136.8, 'currency': 'USD', 'encounter_id': 'cd1eb208-c940-1245-3a22-8bf7a82b61d2'}, {'claim_id': 'cd1eb208-c940-1245-6016-f4b5381b2bd4', 'sequence': 2, 'product_code': '160968000', 'product_display': 'Risk activity involvement (finding)', 'net_amount': None, 'currency': None, 'encounter_id': None}, {'claim_id': '757963e8-7ab5-8fb1-b256-d7aef8dfadd8', 'sequence': 1, 'product_code': '410620009', 'product_display': 'Well child visit (procedure)', 'net_amount': 136.8, 'currency': 'USD', 'encounter_id': '757963e8-7ab5-8fb1-4f55-294e9a908efd'}]
condition216 rows
  • id
  • patient_id
  • encounter_id
  • clinical_status
  • code
  • code_display
  • onset_at
  • recorded_at
3-row preview
[{'id': 'cd1eb208-c940-1245-64cd-6c008392f32f', 'patient_id': 'cd1eb208-c940-1245-d459-caf6402bc11e', 'encounter_id': 'cd1eb208-c940-1245-3a22-8bf7a82b61d2', 'clinical_status': 'active', 'code': '160968000', 'code_display': 'Risk activity involvement (finding)', 'onset_at': '1941-02-22T13:31:40-04:00', 'recorded_at': '1941-02-22T13:31:40-04:00'}, {'id': '6564218e-d42d-30d0-795a-d4aa5456104d', 'patient_id': '6564218e-d42d-30d0-8710-f63c4ab668ce', 'encounter_id': '6564218e-d42d-30d0-103e-14ee971fa953', 'clinical_status': 'resolved', 'code': '314529007', 'code_display': 'Medication review due (situation)', 'onset_at': '2020-09-12T08:16:27-04:00', 'recorded_at': '2020-09-12T08:16:27-04:00'}, {'id': '757963e8-7ab5-8fb1-8c78-3e76a7690e0f', 'patient_id': '757963e8-7ab5-8fb1-170f-e8a18b9bed22', 'encounter_id': '757963e8-7ab5-8fb1-4f55-294e9a908efd', 'clinical_status': 'resolved', 'code': '314529007', 'code_display': 'Medication review due (situation)', 'onset_at': '2016-03-22T17:14:25-04:00', 'recorded_at': '2016-03-22T17:14:25-04:00'}]
encounter295 rows
  • id
  • patient_id
  • organization_id
  • location_id
  • status
  • class_code
  • type_code
  • type_display
  • start_at
  • end_at
3-row preview
[{'id': '6564218e-d42d-30d0-103e-14ee971fa953', 'patient_id': '6564218e-d42d-30d0-8710-f63c4ab668ce', 'organization_id': '9043e647-568d-3e87-9fc0-756a416392d3', 'location_id': 'b6bdd4bc-4675-3537-8229-83d2b83bb394', 'status': 'finished', 'class_code': 'AMB', 'type_code': '410620009', 'type_display': 'Well child visit (procedure)', 'start_at': '2020-09-12T08:16:27-04:00', 'end_at': '2020-09-12T08:31:27-04:00'}, {'id': 'cd1eb208-c940-1245-3a22-8bf7a82b61d2', 'patient_id': 'cd1eb208-c940-1245-d459-caf6402bc11e', 'organization_id': '79508e39-d0b0-3613-9d54-168f6e1c3a18', 'location_id': '720b6888-9941-34d4-8fcb-91343d69d4f2', 'status': 'finished', 'class_code': 'AMB', 'type_code': '410620009', 'type_display': 'Well child visit (procedure)', 'start_at': '1941-02-22T11:53:38-04:00', 'end_at': '1941-02-22T12:08:45-04:00'}, {'id': '0c18b66b-75ce-fdbf-ab8b-6218fa658794', 'patient_id': '0c18b66b-75ce-fdbf-b2a3-45b9068e07f4', 'organization_id': 'c7542447-e06e-32cb-b6db-243c23a0dbc2', 'location_id': '903e1531-4e7b-3e59-9819-f42f3f75236a', 'status': 'finished', 'class_code': 'AMB', 'type_code': '185347001', 'type_display': 'Encounter for problem (procedure)', 'start_at': '2000-12-08T06:04:00-05:00', 'end_at': '2000-12-08T06:19:00-05:00'}]
encounter_participant295 rows
  • encounter_id
  • practitioner_id
  • role_code
3-row preview
[{'encounter_id': '6564218e-d42d-30d0-103e-14ee971fa953', 'practitioner_id': '5265019f-5970-3da5-9941-fee0c92efbb1', 'role_code': 'PPRF'}, {'encounter_id': 'cd1eb208-c940-1245-3a22-8bf7a82b61d2', 'practitioner_id': '501a21a5-eb37-31cd-a857-477dfa190b4a', 'role_code': 'PPRF'}, {'encounter_id': '0c18b66b-75ce-fdbf-ab8b-6218fa658794', 'practitioner_id': '03fd6443-d223-381d-86b0-c40ca7d539c2', 'role_code': 'PPRF'}]
location36 rows
  • id
  • name
  • organization_id
  • city
  • state
3-row preview
[{'id': '1cf1e40b-4ebd-3208-ae22-6a46945b6f5a', 'name': 'CLARITY HEALTH & WELLNESS LLC', 'organization_id': None, 'city': 'BURLINGTON', 'state': 'MA'}, {'id': '720b6888-9941-34d4-8fcb-91343d69d4f2', 'name': 'NASHOBA VALLEY MEDICAL CENTER', 'organization_id': None, 'city': 'GROTON', 'state': 'MA'}, {'id': '903e1531-4e7b-3e59-9819-f42f3f75236a', 'name': 'FRANCISCAN HOSPITAL FOR CHILDREN INC', 'organization_id': None, 'city': 'BOSTON', 'state': 'MA'}]
medication_request100 rows
  • id
  • patient_id
  • encounter_id
  • practitioner_id
  • status
  • medication_code
  • medication_display
  • authored_at
  • dosage_text
3-row preview
[{'id': '0c18b66b-75ce-fdbf-cdd6-38dd45345b99', 'patient_id': '0c18b66b-75ce-fdbf-b2a3-45b9068e07f4', 'encounter_id': '0c18b66b-75ce-fdbf-b53f-7842dc9e3d6f', 'practitioner_id': '03fd6443-d223-381d-86b0-c40ca7d539c2', 'status': 'active', 'medication_code': '997488', 'medication_display': 'Fexofenadine hydrochloride 30 MG Oral Tablet', 'authored_at': '2000-12-25T08:16:36-05:00', 'dosage_text': 'Take as needed.'}, {'id': '0c18b66b-75ce-fdbf-b989-656dc9b51ba5', 'patient_id': '0c18b66b-75ce-fdbf-b2a3-45b9068e07f4', 'encounter_id': '0c18b66b-75ce-fdbf-b53f-7842dc9e3d6f', 'practitioner_id': '03fd6443-d223-381d-86b0-c40ca7d539c2', 'status': 'active', 'medication_code': '1870230', 'medication_display': 'NDA020800 0.3 ML Epinephrine 1 MG/ML Auto-Injector', 'authored_at': '2000-12-25T08:16:36-05:00', 'dosage_text': 'Take as needed.'}, {'id': '6f5397fe-48aa-dd60-a05b-64c8b9891d74', 'patient_id': '6f5397fe-48aa-dd60-3ec3-f846d3442026', 'encounter_id': '6f5397fe-48aa-dd60-1eb9-d96dbfa03312', 'practitioner_id': 'aae724ef-7972-3051-b97a-9c7222d83373', 'status': 'completed', 'medication_code': None, 'medication_display': None, 'authored_at': '2015-10-02T16:07:50-04:00', 'dosage_text': None}]
observation2000 rows
  • id
  • patient_id
  • encounter_id
  • status
  • category_code
  • code
  • code_display
  • effective_at
  • value
  • unit
3-row preview
[{'id': '6564218e-d42d-30d0-8a95-11fbeff09488', 'patient_id': '6564218e-d42d-30d0-8710-f63c4ab668ce', 'encounter_id': '6564218e-d42d-30d0-103e-14ee971fa953', 'status': 'final', 'category_code': 'vital-signs', 'code': '8302-2', 'code_display': 'Body Height', 'effective_at': '2020-09-12T08:16:27-04:00', 'value': 51.8, 'unit': 'cm'}, {'id': '6564218e-d42d-30d0-72a1-5eb3d8d56708', 'patient_id': '6564218e-d42d-30d0-8710-f63c4ab668ce', 'encounter_id': '6564218e-d42d-30d0-103e-14ee971fa953', 'status': 'final', 'category_code': 'vital-signs', 'code': '72514-3', 'code_display': 'Pain severity - 0-10 verbal numeric rating [Score] - Reported', 'effective_at': '2020-09-12T08:16:27-04:00', 'value': 4.0, 'unit': '{score}'}, {'id': '6564218e-d42d-30d0-ba14-7a0482cc77fe', 'patient_id': '6564218e-d42d-30d0-8710-f63c4ab668ce', 'encounter_id': '6564218e-d42d-30d0-103e-14ee971fa953', 'status': 'final', 'category_code': 'vital-signs', 'code': '29463-7', 'code_display': 'Body Weight', 'effective_at': '2020-09-12T08:16:27-04:00', 'value': 3.9, 'unit': 'kg'}]
organization35 rows
  • id
  • name
  • type_code
3-row preview
[{'id': '84d5768f-3a21-3da9-aad2-bbf7a3ae2700', 'name': 'LOWELL FAMILY MEDICAL CARE PC', 'type_code': 'prov'}, {'id': '047f6113-bd42-353b-8368-cf2352868915', 'name': 'BOSTON PELVIC HEALTH AND WELLNESS PC', 'type_code': 'prov'}, {'id': '3d5fbf38-c781-3e04-8c7e-5a402611b7d4', 'name': 'DAVIS SQUARE FAMILY PRACTICE', 'type_code': 'prov'}]
patient10 rows
  • id
  • given_name
  • family_name
  • gender
  • birth_date
  • marital_status
3-row preview
[{'id': '757963e8-7ab5-8fb1-170f-e8a18b9bed22', 'given_name': 'Carolann504', 'family_name': 'Bashirian201', 'gender': 'female', 'birth_date': '2013-10-15', 'marital_status': 'Never Married'}, {'id': '6f5397fe-48aa-dd60-3ec3-f846d3442026', 'given_name': 'Amy965', 'family_name': 'Hagenes547', 'gender': 'female', 'birth_date': '1978-08-30', 'marital_status': 'Married'}, {'id': '8e891115-afb9-bdb7-3b22-f6042ea65d8a', 'given_name': 'Leatrice181', 'family_name': "D'Amore443", 'gender': 'female', 'birth_date': '2021-01-06', 'marital_status': 'Never Married'}]
patient_address10 rows
  • id
  • patient_id
  • line
  • city
  • state
  • postal_code
  • country
  • is_current
3-row preview
[{'id': 1, 'patient_id': '757963e8-7ab5-8fb1-170f-e8a18b9bed22', 'line': '1002 Koss Passage', 'city': 'Weston', 'state': 'MA', 'postal_code': '00000', 'country': 'US', 'is_current': 1}, {'id': 2, 'patient_id': '6f5397fe-48aa-dd60-3ec3-f846d3442026', 'line': '437 Nienow Alley', 'city': 'Winchester', 'state': 'MA', 'postal_code': '01890', 'country': 'US', 'is_current': 1}, {'id': 3, 'patient_id': '8e891115-afb9-bdb7-3b22-f6042ea65d8a', 'line': '549 Koepp Highlands Apt 89', 'city': 'Wareham', 'state': 'MA', 'postal_code': '00000', 'country': 'US', 'is_current': 1}]
practitioner35 rows
  • id
  • given_name
  • family_name
  • gender
3-row preview
[{'id': '5265019f-5970-3da5-9941-fee0c92efbb1', 'given_name': 'Alica364', 'family_name': 'Hartmann983', 'gender': 'female'}, {'id': '2e3ceb4f-1cf9-3aaa-b162-69b631049d6e', 'given_name': 'Enriqueta274', 'family_name': 'Barton704', 'gender': 'female'}, {'id': '713bf341-ab22-3dad-b53f-f6bc7c30d272', 'given_name': 'Elba502', 'family_name': 'Schneider199', 'gender': 'female'}]
procedure806 rows
  • id
  • patient_id
  • encounter_id
  • status
  • code
  • code_display
  • start_at
  • end_at
3-row preview
[{'id': '8e891115-afb9-bdb7-a615-e5e7fff5e5bf', 'patient_id': '8e891115-afb9-bdb7-3b22-f6042ea65d8a', 'encounter_id': '8e891115-afb9-bdb7-3ffd-f469c915ea19', 'status': 'completed', 'code': '430193006', 'code_display': 'Medication reconciliation (procedure)', 'start_at': '2021-01-06T08:49:15-05:00', 'end_at': '2021-01-06T09:04:15-05:00'}, {'id': 'f24a67bb-bd5e-124d-9578-418c642f8ec1', 'patient_id': 'f24a67bb-bd5e-124d-b96d-6f2e394e6c7d', 'encounter_id': 'f24a67bb-bd5e-124d-767b-9d5076d131c8', 'status': 'completed', 'code': '430193006', 'code_display': 'Medication reconciliation (procedure)', 'start_at': '2019-11-16T23:33:14-05:00', 'end_at': '2019-11-16T23:48:14-05:00'}, {'id': '0a4c9694-1422-5288-236e-3ee64072dc39', 'patient_id': '0a4c9694-1422-5288-5dee-731548d4f885', 'encounter_id': '0a4c9694-1422-5288-f2db-0edd3a67e1df', 'status': 'completed', 'code': '430193006', 'code_display': 'Medication reconciliation (procedure)', 'start_at': '2017-10-29T09:46:27-04:00', 'end_at': '2017-10-29T10:01:27-04:00'}]
02

Choose a fact grain and layout

Grain is the contract that prevents accidental double-counting. AI may select only trusted semantic-catalog identifiers; application code compiles the model.

Declared grain: claim — 395 fact rows. Measures: event_count, amount. Dimensions: patient, date, clinical_code, organization.
Drag tables to rearrange this snowflake.
100%
Snowflake analytical modeldim_clinical_codeclinical_code_keycodedisplaycode_system_key3 rowsdim_code_systemcode_system_keysystem_name1 rowsdim_datedate_keyfull_dateyearquartermonthday299 rowsdim_geographygeography_keycitystatecountry9 rowsdim_organizationorganization_keyorganization_idnametype_code35 rowsdim_patientpatient_keypatient_idgiven_namefamily_namegenderbirth_datemarital_statusgeography_keypostal_code10 rowsfact_claimfact_keyevent_idpatient_keydate_keyclinical_code_keyorganization_keyevent_countamount395 rows
dim_clinical_code3 rows
  • clinical_code_key
  • code
  • display
  • code_system_key
3-row preview
[{'clinical_code_key': 1, 'code': 'professional', 'display': 'professional', 'code_system_key': 1}, {'clinical_code_key': 2, 'code': 'pharmacy', 'display': 'pharmacy', 'code_system_key': 1}, {'clinical_code_key': 3, 'code': 'institutional', 'display': 'institutional', 'code_system_key': 1}]
dim_code_system1 rows
  • code_system_key
  • system_name
3-row preview
[{'code_system_key': 1, 'system_name': 'FHIR source coding'}]
dim_date299 rows
  • date_key
  • full_date
  • year
  • quarter
  • month
  • day
3-row preview
[{'date_key': '1941-02-22', 'full_date': '1941-02-22', 'year': 1941, 'quarter': 1, 'month': 2, 'day': 22}, {'date_key': '1942-02-28', 'full_date': '1942-02-28', 'year': 1942, 'quarter': 1, 'month': 2, 'day': 28}, {'date_key': '1942-08-11', 'full_date': '1942-08-11', 'year': 1942, 'quarter': 3, 'month': 8, 'day': 11}]
dim_geography9 rows
  • geography_key
  • city
  • state
  • country
3-row preview
[{'geography_key': 1, 'city': 'Weston', 'state': 'MA', 'country': 'US'}, {'geography_key': 2, 'city': 'Winchester', 'state': 'MA', 'country': 'US'}, {'geography_key': 3, 'city': 'Wareham', 'state': 'MA', 'country': 'US'}]
dim_organization35 rows
  • organization_key
  • organization_id
  • name
  • type_code
3-row preview
[{'organization_key': 1, 'organization_id': '84d5768f-3a21-3da9-aad2-bbf7a3ae2700', 'name': 'LOWELL FAMILY MEDICAL CARE PC', 'type_code': 'prov'}, {'organization_key': 2, 'organization_id': '047f6113-bd42-353b-8368-cf2352868915', 'name': 'BOSTON PELVIC HEALTH AND WELLNESS PC', 'type_code': 'prov'}, {'organization_key': 3, 'organization_id': '3d5fbf38-c781-3e04-8c7e-5a402611b7d4', 'name': 'DAVIS SQUARE FAMILY PRACTICE', 'type_code': 'prov'}]
dim_patient10 rows
  • patient_key
  • patient_id
  • given_name
  • family_name
  • gender
  • birth_date
  • marital_status
  • geography_key
  • postal_code
3-row preview
[{'patient_key': 1, 'patient_id': '757963e8-7ab5-8fb1-170f-e8a18b9bed22', 'given_name': 'Carolann504', 'family_name': 'Bashirian201', 'gender': 'female', 'birth_date': '2013-10-15', 'marital_status': 'Never Married', 'geography_key': 1, 'postal_code': '00000'}, {'patient_key': 2, 'patient_id': '6f5397fe-48aa-dd60-3ec3-f846d3442026', 'given_name': 'Amy965', 'family_name': 'Hagenes547', 'gender': 'female', 'birth_date': '1978-08-30', 'marital_status': 'Married', 'geography_key': 2, 'postal_code': '01890'}, {'patient_key': 3, 'patient_id': '8e891115-afb9-bdb7-3b22-f6042ea65d8a', 'given_name': 'Leatrice181', 'family_name': "D'Amore443", 'gender': 'female', 'birth_date': '2021-01-06', 'marital_status': 'Never Married', 'geography_key': 3, 'postal_code': '00000'}]
fact_claim395 rows
  • fact_key
  • event_id
  • patient_key
  • date_key
  • clinical_code_key
  • organization_key
  • event_count
  • amount
3-row preview
[{'fact_key': 1, 'event_id': 'cd1eb208-c940-1245-6016-f4b5381b2bd4', 'patient_key': 5, 'date_key': '1941-02-22', 'clinical_code_key': 1, 'organization_key': 8, 'event_count': 1, 'amount': 136.8}, {'fact_key': 2, 'event_id': '757963e8-7ab5-8fb1-b256-d7aef8dfadd8', 'patient_key': 1, 'date_key': '2016-03-22', 'clinical_code_key': 1, 'organization_key': 2, 'event_count': 1, 'amount': 136.8}, {'fact_key': 3, 'event_id': '0c18b66b-75ce-fdbf-636c-4708e6ead780', 'patient_key': 6, 'date_key': '2000-12-08', 'clinical_code_key': 1, 'organization_key': 10, 'event_count': 1, 'amount': 85.55}]
Actual compiler-generated DDL
CREATE TABLE dim_geography(geography_key INTEGER PRIMARY KEY, city TEXT, state TEXT, country TEXT, UNIQUE(city,state,country));

CREATE TABLE dim_patient(patient_key INTEGER PRIMARY KEY, patient_id TEXT NOT NULL UNIQUE, given_name TEXT, family_name TEXT, gender TEXT, birth_date TEXT, marital_status TEXT, geography_key INTEGER REFERENCES dim_geography(geography_key), postal_code TEXT);

CREATE TABLE dim_date(date_key TEXT PRIMARY KEY, full_date TEXT NOT NULL, year INTEGER, quarter INTEGER, month INTEGER, day INTEGER);

CREATE TABLE dim_code_system(code_system_key INTEGER PRIMARY KEY, system_name TEXT UNIQUE); CREATE TABLE dim_clinical_code(clinical_code_key INTEGER PRIMARY KEY, code TEXT, display TEXT, code_system_key INTEGER REFERENCES dim_code_system(code_system_key), UNIQUE(code,display));

CREATE TABLE dim_organization(organization_key INTEGER PRIMARY KEY, organization_id TEXT UNIQUE, name TEXT, type_code TEXT);

CREATE TABLE fact_claim(fact_key INTEGER PRIMARY KEY, event_id TEXT UNIQUE, patient_key INTEGER REFERENCES dim_patient(patient_key), date_key TEXT REFERENCES dim_date(date_key), clinical_code_key INTEGER REFERENCES dim_clinical_code(clinical_code_key), organization_key INTEGER REFERENCES dim_organization(organization_key), event_count INTEGER NOT NULL, amount REAL);
Source extraction and fact-load mapping
SELECT e.id event_id, e.patient_id patient_id, substr(e.created_at,1,10) date_key, e.claim_type code, e.claim_type display, e.organization_id organization_id, e.total_amount amount FROM claim e;

-- Trusted compiler resolves natural IDs to surrogate keys and executes:
INSERT INTO fact_claim(event_id,patient_key,date_key,clinical_code_key,organization_key,event_count,amount) VALUES(?,?,?,?,?,?,?);
03

Ask the same business question twice

The result should agree; the SQL shape reveals why dimensional models are convenient for aggregation.

How does claim volume vary by organization, patient state, and year?

The operational query counts claims directly from the normalized claim table, joining organization and the current patient address to get organization name and patient state, and deriving year from claim start_at. The analytical query uses the fact table and dimension tables, reading year from dim_date and aggregating event_count and amount by organization, patient geography state, and year.

Operational

SELECT
  o.name AS organization_name,
  pa.state AS patient_state,
  CAST(strftime('%Y', c.start_at) AS INTEGER) AS year,
  COUNT(*) AS claim_volume,
  SUM(c.total_amount) AS total_amount
FROM claim AS c
JOIN organization AS o
  ON o.id = c.organization_id
JOIN patient AS p
  ON p.id = c.patient_id
JOIN patient_address AS pa
  ON pa.patient_id = p.id
  AND pa.is_current = 1
WHERE c.start_at IS NOT NULL
GROUP BY
  o.name,
  pa.state,
  CAST(strftime('%Y', c.start_at) AS INTEGER)
ORDER BY
  o.name,
  pa.state,
  year
LIMIT 20
3 joins · 4 tables
organization_namepatient_stateyearclaim_volumetotal_amount
AMERICAN CHINESE MEDICAL CENTER PCMA20141136.8
AMERICAN CHINESE MEDICAL CENTER PCMA20161136.8
AMERICAN CHINESE MEDICAL CENTER PCMA201712754.59
AMERICAN CHINESE MEDICAL CENTER PCMA201812072.98
AMERICAN CHINESE MEDICAL CENTER PCMA201912147.56
AMERICAN CHINESE MEDICAL CENTER PCMA202213061.54
AMERICAN CHINESE MEDICAL CENTER PCMA202512997.33
APPLE VALLEY CENTERMA201931102.1200000000001
BAYADA HOME HEALTH CARE, INCMA202023778.23
BAYADA HOME HEALTH CARE, INCMA20211146.18
BENJAMIN HEALTHCARE CENTERMA20192237.9
BOSTON PELVIC HEALTH AND WELLNESS PCMA20162841.0
BOSTON PELVIC HEALTH AND WELLNESS PCMA201721272.3999999999999
BOSTON PELVIC HEALTH AND WELLNESS PCMA201811679.6
BOSTON PELVIC HEALTH AND WELLNESS PCMA20191778.78
BOSTON PELVIC HEALTH AND WELLNESS PCMA202011255.38
BOSTON PELVIC HEALTH AND WELLNESS PCMA20211704.2
BOSTON PELVIC HEALTH AND WELLNESS PCMA20221862.48
BOSTON PELVIC HEALTH AND WELLNESS PCMA20231352.5
BOSTON PELVIC HEALTH AND WELLNESS PCMA202411472.08
EXPLAIN QUERY PLAN
13 | 0 | 0 | SCAN pa
17 | 0 | 0 | SEARCH p USING COVERING INDEX sqlite_autoindex_patient_1 (id=?)
21 | 0 | 0 | SEARCH c USING INDEX idx_claim_patient_date (patient_id=?)
32 | 0 | 0 | SEARCH o USING INDEX sqlite_autoindex_organization_1 (id=?)
38 | 0 | 0 | USE TEMP B-TREE FOR GROUP BY

Analytical

SELECT
  o.name AS organization_name,
  g.state AS patient_state,
  d.year AS year,
  SUM(f.event_count) AS claim_volume,
  SUM(f.amount) AS total_amount
FROM fact_claim AS f
JOIN dim_organization AS o
  ON o.organization_key = f.organization_key
JOIN dim_patient AS p
  ON p.patient_key = f.patient_key
JOIN dim_geography AS g
  ON g.geography_key = p.geography_key
JOIN dim_date AS d
  ON d.date_key = f.date_key
GROUP BY
  o.name,
  g.state,
  d.year
ORDER BY
  o.name,
  g.state,
  d.year
LIMIT 20
4 joins · 5 tables
organization_namepatient_stateyearclaim_volumetotal_amount
AMERICAN CHINESE MEDICAL CENTER PCMA20141136.8
AMERICAN CHINESE MEDICAL CENTER PCMA20161136.8
AMERICAN CHINESE MEDICAL CENTER PCMA201712754.59
AMERICAN CHINESE MEDICAL CENTER PCMA201812072.98
AMERICAN CHINESE MEDICAL CENTER PCMA201912147.56
AMERICAN CHINESE MEDICAL CENTER PCMA202213061.54
AMERICAN CHINESE MEDICAL CENTER PCMA202512997.33
APPLE VALLEY CENTERMA201931102.1200000000001
BAYADA HOME HEALTH CARE, INCMA202023778.23
BAYADA HOME HEALTH CARE, INCMA20211146.18
BENJAMIN HEALTHCARE CENTERMA20192237.9
BOSTON PELVIC HEALTH AND WELLNESS PCMA20162841.0
BOSTON PELVIC HEALTH AND WELLNESS PCMA201721272.3999999999999
BOSTON PELVIC HEALTH AND WELLNESS PCMA201811679.6
BOSTON PELVIC HEALTH AND WELLNESS PCMA20191778.78
BOSTON PELVIC HEALTH AND WELLNESS PCMA202011255.38
BOSTON PELVIC HEALTH AND WELLNESS PCMA20211704.2
BOSTON PELVIC HEALTH AND WELLNESS PCMA20221862.48
BOSTON PELVIC HEALTH AND WELLNESS PCMA20231352.5
BOSTON PELVIC HEALTH AND WELLNESS PCMA202411472.08
EXPLAIN QUERY PLAN
13 | 0 | 0 | SCAN f
15 | 0 | 0 | SEARCH o USING INTEGER PRIMARY KEY (rowid=?)
18 | 0 | 0 | SEARCH p USING INTEGER PRIMARY KEY (rowid=?)
21 | 0 | 0 | SEARCH g USING INTEGER PRIMARY KEY (rowid=?)
24 | 0 | 0 | SEARCH d USING INDEX sqlite_autoindex_dim_date_1 (date_key=?)
30 | 0 | 0 | USE TEMP B-TREE FOR GROUP BY
04

Read-only SQL lab

Only one parsed SELECT/CTE is accepted. Writes, PRAGMA, ATTACH, unknown tables, file functions, long execution, and more than 200 returned rows are blocked.

Operational result

idgiven_namefamily_namegenderbirth_datemarital_status
757963e8-7ab5-8fb1-170f-e8a18b9bed22Carolann504Bashirian201female2013-10-15Never Married
6f5397fe-48aa-dd60-3ec3-f846d3442026Amy965Hagenes547female1978-08-30Married
8e891115-afb9-bdb7-3b22-f6042ea65d8aLeatrice181D'Amore443female2021-01-06Never Married
f24a67bb-bd5e-124d-b96d-6f2e394e6c7dDallas143Bailey598male2019-08-11Never Married
cd1eb208-c940-1245-d459-caf6402bc11eEloise59Senger904female1924-01-05Married
0c18b66b-75ce-fdbf-b2a3-45b9068e07f4Ernesto186Delgado712male2000-01-13Never Married
0a4c9694-1422-5288-5dee-731548d4f885Sheena120Jacobson885female2006-10-15Never Married
f8387f39-1bce-734a-8e6d-2dd0f2928739Ricardo560Satterfield305male1981-02-27Married
a91b8d2d-8d23-f94b-9ec9-481ef2e6fe26Cameron381Leuschke194male1964-10-30Married
6564218e-d42d-30d0-8710-f63c4ab668ceDarell496Mann644male2020-09-12Never Married

Glossary

Grain

Exactly what one fact row represents.

Fact

An event at a declared grain, with foreign keys and measures.

Dimension

Descriptive context used to filter, group, and label facts.

Measure

A numeric value that can be aggregated under defined rules.

Surrogate key

A warehouse-controlled identifier for a dimension row.

ETL / ELT

Extract, transform, and load—the movement from source to analytical structures.

Normalization

Separate entities to reduce redundancy and enforce integrity.

Denormalization

Deliberately repeat or flatten attributes to simplify analytical reads.

Star schema

A central fact joined directly to denormalized dimensions.

Snowflake schema

A dimensional model whose hierarchies are normalized into related tables.