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
TCP vs UDP and Use Cases
00:00
5 left

TCP vs UDP and Use Cases

MediumSQL · PostgreSQL

Problem

Describe the differences between TCP and UDP, including when you would use each and how you would choose between them when designing an application.

Using the provided application, protocol, and connection telemetry tables, write a SQL query that compares TCP and UDP for each application and recommends a protocol based on observed reliability and latency.

Output

  1. One row per application, including applications without telemetry.
  2. Return application name, TCP and UDP event counts, average latency, packet-loss rate, success rate, recommended protocol, and recommendation reason.
  3. Order by application ID ascending. Use NULL for unavailable protocol metrics.

Schema

applications
ColumnTypeDescription
app_idPKINTApplication identifier
app_nameVARCHAR(100)Application name
use_caseVARCHAR(100)Primary application use case
protocols
ColumnTypeDescription
protocol_idPKINTProtocol identifier
protocol_nameVARCHAR(20)Transport protocol name
connection_events
ColumnTypeDescription
event_idPKINTConnection event identifier
app_idINTReferenced application
protocol_idINTReferenced transport protocol
observed_atTIMESTAMPObservation timestamp
latency_msDECIMAL(10,2)Observed round-trip latency in milliseconds
packets_sentINTPackets sent during the event
packets_lostINTPackets lost during the event
event_statusVARCHAR(20)Connection outcome
Tablesapplicationsprotocolsconnection_events
Interviewer

Your question is TCP vs UDP and Use Cases. 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.