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
Schema for Consumer Requirements
00:00
5 left

Schema for Consumer Requirements

MediumSQL · PostgreSQL

Problem

Design a schema model for a consumer requirement.

Use a normalized model in which consumers can have many requirements, and requirements can be associated with many consumers. Include a query that reports the requirement summary for every consumer, including consumers with no assignments.

Output

  1. One row per consumer
  2. Columns: consumer_id, consumer_name, active_requirement_count, and last_assigned_at
  3. Include consumers without assignments, with a count of zero and a null latest-assignment date
  4. Order by active requirement count descending, then consumer ID ascending

Schema

consumers
ColumnTypeDescription
consumer_idPKINTUnique consumer identifier
consumer_nameVARCHAR(100)Consumer display name
emailVARCHAR(255)Consumer email address
requirements
ColumnTypeDescription
requirement_idPKINTUnique requirement identifier
requirement_nameVARCHAR(120)Requirement name
descriptionTEXTRequirement details
statusVARCHAR(20)Requirement lifecycle status
consumer_requirements
ColumnTypeDescription
consumer_idPKINTReferenced consumer
requirement_idPKINTReferenced requirement
assigned_atDATEDate the requirement was assigned
assignment_noteTEXTOptional note about the assignment
Tablesconsumersrequirementsconsumer_requirements
Interviewer

Your question is Schema for Consumer Requirements. 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.