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
Message Routing with Multiple Providers
00:00
5 left

Message Routing with Multiple Providers

MediumSQL · PostgreSQL

Problem

Machine coding: build a communication service handling multiple request types (Email, SMS, Soundbox) with per-type mandatory fields; providers support one or more channels, multiple providers per channel, providers have multiple accounts (e.g. for critical OTP traffic); randomly select one active eligible provider per request. Asked in the Machine coding stage.

Output

  1. Return one row per valid request with request_id, request_type, account_id, and provider_name.
  2. Exclude requests missing their type-specific mandatory field or lacking an eligible account.
  3. Select only active providers and accounts, require critical OTP support when applicable, and order by request_id.

Schema

communication_requests
ColumnTypeDescription
request_idPKINTCommunication request identifier
request_typeVARCHAR(20)Requested channel: EMAIL, SMS, or SOUNDBOX
email_addressVARCHAR(255)Required for email requests
phone_numberVARCHAR(30)Required for SMS requests
soundbox_device_idVARCHAR(50)Required for Soundbox requests
is_critical_otpBOOLEANWhether the request requires a critical OTP-capable account
providers
ColumnTypeDescription
provider_idPKINTProvider identifier
provider_nameVARCHAR(100)Provider display name
supported_channelsTEXT[]Channels supported by the provider
is_activeBOOLEANWhether the provider can receive new requests
provider_accounts
ColumnTypeDescription
account_idPKINTProvider account identifier
provider_idINTReferenced provider
account_nameVARCHAR(100)Provider account label
is_activeBOOLEANWhether the account is available
supports_critical_otpBOOLEANWhether the account supports critical OTP traffic
Tablescommunication_requestsprovidersprovider_accounts
Interviewer

Your question is Message Routing with Multiple Providers. 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.