This page requires JavaScript to display.
C
Unpacking...
← Advanced Data Engineering
Advanced Data Engineering

Data Modelling Case Studies

Six realistic systems modelled end to end: requirements, entities, a tested OLTP schema, an analytics star schema and the queries the business asks.

Contents
1. How to Approach a Modelling Problem 2. Banking System 3. Cab Booking Platform 4. E-commerce Platform 5. Video Streaming Service 6. Online Learning Platform 7. Hospital Network

1. How to Approach a Modelling Problem

Every modelling interview question ("design the database for a cab booking app") is answered the same way. Interviewers want to see the process as much as the final tables.

StepWhat to do
1. Clarify scopeWhich features? Which users? Scale (rows per day)? Transactions or analytics?
2. List entitiesNouns in the requirements: rider, driver, trip, payment
3. Relationships and cardinality1:1, 1:N, M:N; resolve M:N with associative tables
4. Keys and constraintsPrimary, foreign, unique, check; natural vs surrogate keys
5. Lifecycle and historyStatus changes, events, SCD needs, soft deletes, audit
6. Access patternsThe top queries; indexes, partitioning, denormalisation
7. Analytics modelFacts at a declared grain, conformed dimensions
8. Edge casesConcurrency, money and time zones, privacy, idempotency

The six case studies below follow these steps. Each OLTP schema was created and loaded with sample rows in DuckDB, and every query result shown is real.

2. Banking System

Scope: customers with KYC, accounts (savings, current, loan), joint accounts, deposits, transfers and withdrawals, statements. Non-negotiables: money is never created or lost, every change is auditable, retries never post twice.

Key design decisions

CREATE TABLE customer (customer_id INT PRIMARY KEY, full_name VARCHAR NOT NULL, kyc_status VARCHAR NOT NULL,
                       date_of_birth DATE, created_at TIMESTAMP);
CREATE TABLE account  (account_id INT PRIMARY KEY, account_type VARCHAR CHECK (account_type IN ('SAVINGS','CURRENT','LOAN')),
                       currency CHAR(3) NOT NULL, opened_on DATE, status VARCHAR NOT NULL);
CREATE TABLE account_holder (account_id INT REFERENCES account, customer_id INT REFERENCES customer,
                             role VARCHAR CHECK (role IN ('PRIMARY','JOINT')), PRIMARY KEY (account_id, customer_id));
-- double-entry ledger: every journal entry's postings sum to zero
CREATE TABLE journal_entry (entry_id INT PRIMARY KEY, posted_at TIMESTAMP NOT NULL, description VARCHAR,
                            idempotency_key VARCHAR UNIQUE NOT NULL);       -- retries cannot post twice
CREATE TABLE posting (entry_id INT REFERENCES journal_entry, account_id INT REFERENCES account,
                      amount DECIMAL(18,2) NOT NULL,                        -- + credit, - debit
                      PRIMARY KEY (entry_id, account_id));

Every entry must balance, and balances are derived

SELECT entry_id, SUM(amount) AS must_be_zero FROM posting GROUP BY entry_id ORDER BY entry_id;
entry_idmust_be_zero
10.00
20.00
30.00
-- WRONG: holders joined before summing
SELECT a.account_id, a.account_type, SUM(p.amount) AS balance,
       STRING_AGG(c.full_name || ' (' || h.role || ')', ', ' ORDER BY h.role DESC) AS holders
FROM account a
JOIN posting p USING (account_id)
JOIN account_holder h USING (account_id)
JOIN customer c USING (customer_id)
WHERE a.account_id <> 9000
GROUP BY a.account_id, a.account_type ORDER BY a.account_id;
account_idaccount_typebalanceholders
1000CURRENT25,000.00Asha Rao (PRIMARY), Asha Rao (PRIMARY), Asha Rao (PRIMARY)
2000SAVINGS40,000.00Ravi Kumar (PRIMARY), Asha Rao (JOINT)

This version is wrong: joint account 2000 has two holders, so its single 20,000 posting is counted twice (40,000), and Asha is listed once per posting on account 1000. It is the same fan-out problem as joining two fact tables. Aggregate the postings first, then attach the holders:

-- RIGHT: sum postings per account first, then attach holders
WITH bal AS (SELECT account_id, SUM(amount) AS balance FROM posting GROUP BY account_id)
SELECT b.account_id, b.balance,
       (SELECT STRING_AGG(c.full_name, ', ') FROM account_holder h JOIN customer c USING (customer_id)
        WHERE h.account_id = b.account_id) AS holders
FROM bal b WHERE b.account_id <> 9000 ORDER BY b.account_id;
account_idbalanceholders
100025,000.00Asha Rao
200020,000.00Asha Rao, Ravi Kumar

Analytics model

TableType and grain
fact_transactionTransaction fact: one row per posting (account, date, channel, amount)
fact_daily_balancePeriodic snapshot: one row per account per day (semi-additive balance)
dim_customerSCD2 (segment, KYC status, address over time)
dim_account, dim_date, dim_channel, dim_branchConformed dimensions
Say this in the interview

"For banking I use a double-entry ledger: journal entries whose postings sum to zero, balances derived from postings, immutable rows with reversing entries for corrections, DECIMAL money, and an idempotency key so retries never post twice. Joint accounts are M:N through account_holder. Analytics uses a transaction fact plus a daily balance snapshot, with SCD2 customers."

3. Cab Booking Platform

Scope: riders request trips, drivers accept, trips move through statuses, fares include surge pricing, payments and ratings. Scale: millions of trips a day and GPS pings every few seconds, which do not belong in the OLTP database.

Key design decisions

CREATE TABLE rider  (rider_id INT PRIMARY KEY, name VARCHAR, phone VARCHAR UNIQUE, rating DECIMAL(3,2));
CREATE TABLE driver (driver_id INT PRIMARY KEY, name VARCHAR, licence_no VARCHAR UNIQUE, rating DECIMAL(3,2));
CREATE TABLE vehicle (vehicle_id INT PRIMARY KEY, driver_id INT REFERENCES driver, category VARCHAR, plate VARCHAR UNIQUE);
CREATE TABLE zone (zone_id INT PRIMARY KEY, city VARCHAR, name VARCHAR);
CREATE TABLE trip (trip_id INT PRIMARY KEY, rider_id INT REFERENCES rider, driver_id INT REFERENCES driver,
                   pickup_zone INT REFERENCES zone, drop_zone INT REFERENCES zone,
                   status VARCHAR CHECK (status IN ('REQUESTED','ACCEPTED','STARTED','COMPLETED','CANCELLED')),
                   requested_at TIMESTAMP, accepted_at TIMESTAMP, started_at TIMESTAMP, completed_at TIMESTAMP,
                   surge_multiplier DECIMAL(3,2) DEFAULT 1.0, fare DECIMAL(10,2), distance_km DECIMAL(6,2));
CREATE TABLE trip_event (trip_id INT REFERENCES trip, event_time TIMESTAMP, status VARCHAR,   -- full status history
                         lat DECIMAL(9,6), lon DECIMAL(9,6));
CREATE TABLE payment (payment_id INT PRIMARY KEY, trip_id INT REFERENCES trip UNIQUE, method VARCHAR, amount DECIMAL(10,2), status VARCHAR);

Operational metrics

SELECT z.name AS pickup_zone,
       COUNT(*)                                                          AS requests,
       COUNT(*) FILTER (WHERE status = 'COMPLETED')                      AS completed,
       ROUND(100.0 * COUNT(*) FILTER (WHERE status = 'CANCELLED') / COUNT(*), 1) AS cancel_pct,
       ROUND(AVG(DATE_DIFF('minute', requested_at, started_at)), 1)      AS avg_wait_min,
       ROUND(AVG(fare / distance_km), 1)                                 AS fare_per_km
FROM trip t JOIN zone z ON z.zone_id = t.pickup_zone
GROUP BY z.name ORDER BY requests DESC;
pickup_zonerequestscompletedcancel_pctavg_wait_minfare_per_km
Airport3233.312.524.3
Hinjewadi110.010.021.4
Koregaon Park10100.0NULLNULL
SELECT d.name AS driver,
       COUNT(*) FILTER (WHERE t.status = 'COMPLETED')      AS trips,
       SUM(t.fare)                                          AS earnings,
       ROUND(SUM(t.distance_km), 1)                         AS km
FROM driver d LEFT JOIN trip t ON t.driver_id = d.driver_id
GROUP BY d.name ORDER BY earnings DESC;
drivertripsearningskm
Leela2780.0035.00
Kiran1540.0021.00

Analytics model

TableType and grain
fact_tripAccumulating snapshot: one row per trip with requested, accepted, started, completed timestamps and durations between them
fact_trip_eventTransaction fact: one row per status change
fact_driver_hourPeriodic snapshot: online minutes, trips, earnings per driver per hour
dim_rider, dim_driver (SCD2), dim_vehicle, dim_zone, dim_date, dim_timeDimensions; dim_zone plays pickup and drop roles
Say this in the interview

"A trip has a status lifecycle, so I keep current status and milestone timestamps on the trip and append every transition to a trip_event table. Fares and surge are frozen at booking. GPS pings go to a stream and the lake, not the OLTP database. For analytics, fact_trip is an accumulating snapshot, zone is a role-playing dimension for pickup and drop, and I add an hourly driver snapshot for supply metrics."

4. E-commerce Platform

Scope: catalogue with variants, inventory per warehouse, carts, orders, payments, shipments, returns and reviews. Traps: prices change, addresses change, products have variants, returns are partial.

Key design decisions

CREATE TABLE customer (customer_id INT PRIMARY KEY, email VARCHAR UNIQUE NOT NULL, created_at TIMESTAMP);
CREATE TABLE category (category_id INT PRIMARY KEY, name VARCHAR, parent_id INT);   -- tree: parent_id -> category_id
CREATE TABLE product  (product_id INT PRIMARY KEY, name VARCHAR, category_id INT REFERENCES category, brand VARCHAR);
CREATE TABLE sku      (sku_id INT PRIMARY KEY, product_id INT REFERENCES product, size VARCHAR, colour VARCHAR,
                       list_price DECIMAL(10,2) NOT NULL);                                            -- sellable variant
CREATE TABLE inventory (sku_id INT REFERENCES sku, warehouse VARCHAR, on_hand INT CHECK (on_hand >= 0),
                        PRIMARY KEY (sku_id, warehouse));
CREATE TABLE orders   (order_id INT PRIMARY KEY, customer_id INT REFERENCES customer, ordered_at TIMESTAMP,
                       status VARCHAR, shipping_address VARCHAR);                    -- address copied at order time
CREATE TABLE order_item (order_id INT REFERENCES orders, line_no INT, sku_id INT REFERENCES sku, qty INT CHECK (qty > 0),
                         unit_price DECIMAL(10,2) NOT NULL, discount DECIMAL(10,2) DEFAULT 0,   -- price charged
                         PRIMARY KEY (order_id, line_no));
CREATE TABLE return_item (order_id INT, line_no INT, returned_qty INT, reason VARCHAR, refunded DECIMAL(10,2),
                          FOREIGN KEY (order_id, line_no) REFERENCES order_item (order_id, line_no));

Net revenue by top-level category, after returns

WITH RECURSIVE tree AS (
  SELECT category_id, name AS top_category FROM category WHERE parent_id IS NULL
  UNION ALL
  SELECT c.category_id, t.top_category FROM category c JOIN tree t ON c.parent_id = t.category_id
),
lines AS (
  SELECT oi.order_id, oi.line_no, p.category_id,
         oi.qty * oi.unit_price - oi.discount AS gross,
         COALESCE(r.refunded, 0)               AS refunded
  FROM order_item oi
  JOIN sku s USING (sku_id) JOIN product p USING (product_id)
  LEFT JOIN return_item r USING (order_id, line_no)
)
SELECT t.top_category, SUM(gross) AS gross, SUM(refunded) AS refunds, SUM(gross - refunded) AS net
FROM lines l JOIN tree t USING (category_id)
GROUP BY t.top_category ORDER BY net DESC;
top_categorygrossrefundsnet
Fashion5,900.001,100.004,800.00
Electronics2,600.000.002,600.00
SELECT s.sku_id, p.name, s.size, SUM(i.on_hand) AS on_hand,
       CASE WHEN SUM(i.on_hand) = 0 THEN 'OUT OF STOCK' ELSE 'available' END AS status
FROM sku s JOIN product p USING (product_id) JOIN inventory i USING (sku_id)
GROUP BY s.sku_id, p.name, s.size ORDER BY s.sku_id;
sku_idnamesizeon_handstatus
100Linen ShirtM40available
101Linen ShirtL0OUT OF STOCK
102Summer DressS12available
103EarbudsNULL25available

Analytics model

TableType and grain
fact_order_lineOne row per order line: qty, gross, discount, tax, net
fact_return_lineOne row per returned line (combine with sales via drill-across, not a direct join)
fact_inventory_dailyPeriodic snapshot per SKU per warehouse per day
fact_web_sessionFunnel: views, add-to-cart, checkout, purchase
dim_product (SCD2 on category, brand), dim_customer, dim_date, dim_warehouse, dim_promotionDimensions
Say this in the interview

"I separate product from SKU, keep inventory per SKU per warehouse, model categories as a tree, and snapshot price, discount and address on the order line so history never changes. Returns are line-level for partial refunds. Analytics has an order-line fact, a return fact combined by drill-across, a daily inventory snapshot and a web funnel fact."

5. Video Streaming Service

Scope: accounts with subscription plans, several profiles per account, a catalogue of movies and series with seasons and episodes, genres, and playback. Scale: playback emits heartbeat events every few seconds for millions of concurrent streams, so viewing data is modelled for the lakehouse, not the OLTP database.

Key design decisions

CREATE TABLE account (account_id INT PRIMARY KEY, email VARCHAR UNIQUE, country CHAR(2), created_at DATE);
CREATE TABLE plan (plan_id INT PRIMARY KEY, name VARCHAR, max_streams INT, monthly_price DECIMAL(8,2));
CREATE TABLE subscription (account_id INT REFERENCES account, plan_id INT REFERENCES plan,
                           valid_from DATE, valid_to DATE, PRIMARY KEY (account_id, valid_from));   -- plan history
CREATE TABLE profile (profile_id INT PRIMARY KEY, account_id INT REFERENCES account, name VARCHAR, is_kids BOOLEAN);
CREATE TABLE title (title_id INT PRIMARY KEY, name VARCHAR, title_type VARCHAR CHECK (title_type IN ('MOVIE','SERIES')),
                    release_year INT, maturity_rating VARCHAR);
CREATE TABLE episode (episode_id INT PRIMARY KEY, title_id INT REFERENCES title, season INT, episode_no INT, runtime_min INT);
CREATE TABLE genre (genre_id INT PRIMARY KEY, name VARCHAR);
CREATE TABLE title_genre (title_id INT REFERENCES title, genre_id INT REFERENCES genre, PRIMARY KEY (title_id, genre_id));
-- high-volume events: in production these stream to Kafka and the lakehouse, partitioned by date
CREATE TABLE playback_session (session_id VARCHAR PRIMARY KEY, profile_id INT REFERENCES profile,
                               episode_id INT REFERENCES episode, device VARCHAR,
                               started_at TIMESTAMP, watched_min INT);

Completion rate per title, and binge sessions

SELECT t.name, COUNT(*) AS plays, SUM(ps.watched_min) AS minutes,
       ROUND(100.0 * AVG(LEAST(ps.watched_min::DOUBLE / e.runtime_min, 1)), 1) AS avg_completion_pct
FROM playback_session ps
JOIN episode e USING (episode_id) JOIN title t USING (title_id)
GROUP BY t.name ORDER BY minutes DESC;
nameplaysminutesavg_completion_pct
Data Heist414070.4
The Pipeline14033.9
Ocean Tales125100.0
-- a binge: consecutive episodes of one series within 15 minutes of the previous one ending
WITH s AS (
  SELECT p.name AS profile, t.name AS title, ps.started_at, ps.watched_min,
         LAG(ps.started_at + INTERVAL (ps.watched_min) MINUTE)
           OVER (PARTITION BY ps.profile_id, e.title_id ORDER BY ps.started_at) AS prev_end
  FROM playback_session ps JOIN episode e USING (episode_id) JOIN title t USING (title_id)
  JOIN profile p USING (profile_id)
)
SELECT profile, title, COUNT(*) + 1 AS episodes_in_a_row
FROM s
WHERE started_at - prev_end <= INTERVAL 15 MINUTE
GROUP BY profile, title;
profiletitleepisodes_in_a_row
AshaData Heist3

Analytics model

TableType and grain
fact_playback_sessionOne row per session: profile, episode, device, minutes, completion
fact_subscription_monthPeriodic snapshot: one row per account per month (plan, MRR, churn flag)
fact_title_dailyAggregate: views and minutes per title per country per day
dim_title (with bridge to genres), dim_profile, dim_device, dim_date, dim_countryDimensions; genre is multi-valued, handled with a bridge table
Say this in the interview

"I split account (billing) from profile (viewing), keep subscription history with validity dates for revenue and churn, model title to episode as a hierarchy and genres as M:N. Playback heartbeats are too voluminous for OLTP, so they stream to the lakehouse and are sessionised into a playback-session fact, used for completion rates, binge analysis and recommendations."

6. Online Learning Platform

Scope: an upskilling platform with a structured program (modules and lessons), cohorts, mentors, progress tracking, assessments and mock interviews. Questions the business asks: where do learners drop off, which mentors are overloaded, how do assessment scores relate to interview performance?

Key design decisions

CREATE TABLE learner (learner_id INT PRIMARY KEY, name VARCHAR, email VARCHAR UNIQUE, experience_years INT);
CREATE TABLE mentor  (mentor_id INT PRIMARY KEY, name VARCHAR, company VARCHAR, max_learners INT);
CREATE TABLE program (program_id INT PRIMARY KEY, name VARCHAR, version INT);              -- versioned curriculum
CREATE TABLE module  (module_id INT PRIMARY KEY, program_id INT REFERENCES program, seq INT, name VARCHAR);
CREATE TABLE lesson  (lesson_id INT PRIMARY KEY, module_id INT REFERENCES module, seq INT, name VARCHAR, kind VARCHAR);
CREATE TABLE cohort  (cohort_id INT PRIMARY KEY, program_id INT REFERENCES program, start_date DATE);
CREATE TABLE enrolment (learner_id INT REFERENCES learner, cohort_id INT REFERENCES cohort, mentor_id INT REFERENCES mentor,
                        status VARCHAR CHECK (status IN ('ACTIVE','PAUSED','COMPLETED','DROPPED')),
                        enrolled_on DATE, PRIMARY KEY (learner_id, cohort_id));
CREATE TABLE lesson_progress (learner_id INT, lesson_id INT REFERENCES lesson, completed_at TIMESTAMP,
                              score INT, PRIMARY KEY (learner_id, lesson_id));
CREATE TABLE mock_interview (interview_id INT PRIMARY KEY, learner_id INT, mentor_id INT, held_on DATE,
                             topic VARCHAR, rating INT CHECK (rating BETWEEN 1 AND 5));

Progress funnel by module

SELECT m.seq, m.name AS module,
       COUNT(DISTINCT lp.learner_id)                                      AS learners_started,
       ROUND(100.0 * COUNT(lp.lesson_id) /
             (COUNT(DISTINCT l.lesson_id) * (SELECT COUNT(*) FROM enrolment)), 1) AS completion_pct
FROM module m
JOIN lesson l USING (module_id)
LEFT JOIN lesson_progress lp USING (lesson_id)
GROUP BY m.seq, m.name ORDER BY m.seq;
seqmodulelearners_startedcompletion_pct
1Programming377.8
2Fundamentals250.0
3Tools133.3
SELECT me.name AS mentor, me.max_learners,
       COUNT(DISTINCT e.learner_id)                 AS assigned,   -- DISTINCT: mocks multiply rows
       ROUND(AVG(mi.rating), 1)                     AS avg_mock_rating,
       COUNT(mi.interview_id)                       AS mocks_held
FROM mentor me
LEFT JOIN enrolment e ON e.mentor_id = me.mentor_id
LEFT JOIN mock_interview mi ON mi.mentor_id = me.mentor_id AND mi.learner_id = e.learner_id
GROUP BY me.name, me.max_learners ORDER BY me.name;
mentormax_learnersassignedavg_mock_ratingmocks_held
Arjun324.03
Pooja31NULL0

Analytics model

TableType and grain
fact_lesson_completionOne row per learner per lesson completed (with score)
fact_learner_weekPeriodic snapshot: progress %, active days, status per learner per week
fact_mock_interviewOne row per mock interview with rating
dim_learner, dim_mentor, dim_lesson (with module and program version), dim_cohort, dim_dateDimensions
Say this in the interview

"I model program, module and lesson as a versioned hierarchy, cohorts as runs of a program, and enrolment as the learner-cohort link carrying mentor and status. Progress is one row per learner per lesson. Analytics uses a completion fact and a weekly learner snapshot to find drop-off points and correlate assessment scores with mock interview ratings."

7. Hospital Network

Scope: several hospitals with departments, doctors, patients, appointments, admissions with beds, diagnoses coded in ICD-10, billing and insurance claims. Constraints: patient data is highly sensitive health information, regulated by laws such as India's DPDP Act, HIPAA in the US and GDPR in Europe.

Key design decisions

CREATE TABLE hospital (hospital_id INT PRIMARY KEY, name VARCHAR, city VARCHAR);
CREATE TABLE department (dept_id INT PRIMARY KEY, hospital_id INT REFERENCES hospital, name VARCHAR);
CREATE TABLE doctor (doctor_id INT PRIMARY KEY, name VARCHAR, specialty VARCHAR, dept_id INT REFERENCES department);
CREATE TABLE patient (patient_id INT PRIMARY KEY, mrn VARCHAR UNIQUE,            -- medical record number
                      full_name VARCHAR, date_of_birth DATE, phone VARCHAR);      -- PHI: restricted access
CREATE TABLE bed (bed_id INT PRIMARY KEY, dept_id INT REFERENCES department, ward VARCHAR, bed_type VARCHAR);
CREATE TABLE appointment (appointment_id INT PRIMARY KEY, patient_id INT REFERENCES patient, doctor_id INT REFERENCES doctor,
                          scheduled_at TIMESTAMP, status VARCHAR CHECK (status IN ('BOOKED','COMPLETED','NO_SHOW','CANCELLED')));
CREATE TABLE admission (admission_id INT PRIMARY KEY, patient_id INT REFERENCES patient, hospital_id INT REFERENCES hospital,
                        bed_id INT REFERENCES bed, attending_doctor INT REFERENCES doctor,
                        admitted_at TIMESTAMP NOT NULL, discharged_at TIMESTAMP, discharge_type VARCHAR);
CREATE TABLE diagnosis (admission_id INT REFERENCES admission, icd10_code VARCHAR, is_primary BOOLEAN,
                        PRIMARY KEY (admission_id, icd10_code));
CREATE TABLE bill (bill_id INT PRIMARY KEY, admission_id INT REFERENCES admission, total DECIMAL(12,2),
                   insurer VARCHAR, claim_status VARCHAR);

Average length of stay and 30-day readmissions

SELECT h.name AS hospital,
       COUNT(*)                                                                    AS admissions,
       ROUND(AVG(DATE_DIFF('hour', admitted_at, discharged_at)) / 24.0, 1)         AS avg_los_days,
       COUNT(*) FILTER (WHERE discharged_at IS NULL)                               AS currently_admitted
FROM admission a JOIN hospital h USING (hospital_id)
GROUP BY h.name ORDER BY h.name;
hospitaladmissionsavg_los_dayscurrently_admitted
City Hospital North34.61
City Hospital South12.00
WITH ordered AS (
  SELECT patient_id, admission_id, admitted_at, discharged_at,
         LEAD(admitted_at) OVER (PARTITION BY patient_id ORDER BY admitted_at) AS next_admission
  FROM admission
)
SELECT 'P' || LPAD(CAST(patient_id AS VARCHAR), 4, '0') AS patient_ref,     -- pseudonymised in output
       admission_id, discharged_at::DATE AS discharged,
       next_admission::DATE AS readmitted,
       DATE_DIFF('day', discharged_at, next_admission) AS days_between
FROM ordered
WHERE next_admission IS NOT NULL AND next_admission <= discharged_at + INTERVAL 30 DAY;
patient_refadmission_iddischargedreadmitteddays_between
P000112026-02-062026-02-2014
SELECT d.name AS department, COUNT(b.bed_id) AS beds,
       COUNT(a.admission_id) AS occupied_now,
       ROUND(100.0 * COUNT(a.admission_id) / COUNT(b.bed_id), 0) AS occupancy_pct
FROM department d
JOIN bed b USING (dept_id)
LEFT JOIN admission a ON a.bed_id = b.bed_id AND a.discharged_at IS NULL
GROUP BY d.name ORDER BY d.name;
departmentbedsoccupied_nowoccupancy_pct
Cardiology200.0
General Medicine11100.0
Orthopaedics100.0

Analytics model

TableType and grain
fact_admissionAccumulating snapshot: one row per admission with admit, discharge, length of stay, cost, readmission flag
fact_appointmentOne row per appointment with status (no-show analysis)
fact_bed_dailyPeriodic snapshot: occupancy per bed per day
bridge_admission_diagnosisMulti-valued diagnoses per admission
dim_patient (pseudonymised, age band not birth date), dim_doctor, dim_department, dim_hospital, dim_diagnosis (ICD-10 hierarchy), dim_dateDimensions
Say this in the interview

"A hospital model centres on the patient, identified across branches by an MRN, with admissions as episodes, ICD-10 coded diagnoses through a bridge, beds and billing. Privacy drives the design: identifiers stay in one restricted table, analytics uses pseudonymised keys and age bands, and access is audited. Key metrics like length of stay, 30-day readmission and bed occupancy come from an admission accumulating snapshot and a daily bed snapshot."