Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Schema for Billing Cycles
00:00
5 left

Schema for Billing Cycles

HardSQL · PostgreSQL

Problem

How would you design a schema to track patient billing cycles over time at Candid Health?

Represent patients, billing cycles, and cycle events, then return a chronological cycle history that shows prior-cycle context and the latest recorded event for each cycle.

Output

  1. One row per billing cycle, excluding patients without cycles
  2. Columns: patient identity, cycle dates and status, billed amount, prior cycle status, days between cycles, latest event type, and latest event timestamp
  3. Sort by patient ID, cycle start date, and cycle ID

Schema

patients
ColumnTypeDescription
patient_idPKINTUnique patient identifier
patient_nameVARCHAR(120)Patient display name
external_patient_keyVARCHAR(50)Optional identifier from a connected provider system
billing_cycles
ColumnTypeDescription
cycle_idPKINTUnique billing-cycle identifier
patient_idINTPatient associated with the cycle
cycle_start_dateDATEDate the billing cycle began
cycle_end_dateDATEDate the billing cycle ended, NULL for an open cycle
cycle_statusVARCHAR(30)Current lifecycle status of the cycle
payer_nameVARCHAR(100)Payer associated with the cycle
billed_amountNUMERIC(12,2)Amount billed for the cycle
billing_events
ColumnTypeDescription
event_idPKINTUnique billing event identifier
cycle_idINTBilling cycle affected by the event
event_typeVARCHAR(40)Event recorded for the billing cycle
event_atTIMESTAMPTimestamp when the event occurred
event_noteTEXTOptional operational note
Tablespatientsbilling_cyclesbilling_events
Interviewer

Your question is Schema for Billing Cycles. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.