Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Relational Schema for Personality Assessments
00:00
5 left

Relational Schema for Personality Assessments

MediumSQL · PostgreSQL

Problem

Explain how you would structure a relational database schema to support a multi-question, multi-dimension personality assessment.

For this SQL exercise, use the provided assessment, question, response, and answer data model. Write a PostgreSQL query that reports dimension-level scores for assessment 1, excluding respondents without scored answers.

Output

  1. One row per respondent and personality dimension
  2. Columns: respondent_id, dimension, answered_questions, and average_score
  3. Include only dimensions with at least one non-null score
  4. Order by respondent_id, then dimension

Schema

questions
ColumnTypeDescription
question_idPKINTUnique question identifier
assessment_idINTAssessment version containing the question
dimensionVARCHAR(50)Personality dimension measured by the question
promptTEXTQuestion text presented to the respondent
responses
ColumnTypeDescription
response_idPKINTUnique assessment response identifier
assessment_idINTAssessment version being completed
respondent_idINTPerson completing the assessment
completed_atDATEDate the assessment was completed
answers
ColumnTypeDescription
answer_idPKINTUnique answer identifier
response_idINTAssessment response containing the answer
question_idINTQuestion being answered
scoreINTNumeric response score, from 1 to 5 when answered
Tablesquestionsresponsesanswers
Interviewer

Your question is Relational Schema for Personality Assessments. 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.