Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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

Your question is Join Types in Star Schemas. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.