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
Cardinality in Data Modeling
00:00
5 left

Cardinality in Data Modeling

MediumSQL · PostgreSQL

Problem

Can you explain your experience with data modeling and handling cardinality in your projects for KPMG clients?

Use the supplied client, project, and project assignment tables to demonstrate this with a query. Return every client, including clients without projects, while avoiding inflated counts caused by one-to-many relationships.

Output

  1. One row per client with client_name, project_count, assignment_count, and total_hours
  2. Include clients with no related projects or assignments, using zero totals
  3. Order by total_hours descending, then client_name ascending

Schema

clients
ColumnTypeDescription
client_idPKINTUnique client identifier
client_nameVARCHAR(100)Client name
projects
ColumnTypeDescription
project_idPKINTUnique project identifier
client_idINTClient associated with the project
project_nameVARCHAR(120)Project name
project_assignments
ColumnTypeDescription
assignment_idPKINTUnique assignment identifier
project_idINTProject receiving the assignment
assignee_nameVARCHAR(100)Assigned team member
hoursDECIMAL(10,2)Hours recorded for the assignment
Tablesclientsprojectsproject_assignments
Interviewer

Your question is Cardinality in Data Modeling. 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.