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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Join Types in Star Schemas
00:00
5 left

Join Types in Star Schemas

MediumSQL · PostgreSQL

Problem

Can you explain the difference between various join types and when to use them in a star schema?

Use the provided fact and dimension tables to demonstrate the appropriate join behavior for preserving every fact row, including rows with missing dimension matches.

Output

  1. One row per encounter with encounter_id, encounter_date, patient_name, and service_name.
  2. Include all encounters, retain NULLs for missing dimension matches, and order by encounter_id ascending.

Schema

fact_encounters
ColumnTypeDescription
encounter_idPKINTEGERUnique encounter identifier
encounter_dateDATEDate of the encounter
patient_idINTEGERPatient dimension key
service_idINTEGERService dimension key
dim_patient
ColumnTypeDescription
patient_idPKINTEGERUnique patient dimension key
patient_nameVARCHAR(100)Patient display name
dim_service
ColumnTypeDescription
service_idPKINTEGERUnique service dimension key
service_nameVARCHAR(100)Service display name
Tablesfact_encountersdim_patientdim_service
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

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.