Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Validating Data Models
00:00
5 left

Validating Data Models

MediumSQL · PostgreSQL

Problem

Describe your process for validating data models before presenting them to stakeholders.

Use the supplied customers, policies, and policy_transactions tables. Write a query that identifies policy records whose modeled transaction counts or amounts do not reconcile with source transactions, or whose customer reference is missing.

Output

  1. One row per invalid policy record
  2. Include policy_id, model_status, customer_id, customer_name, modeled and source transaction counts, modeled and source amounts, and validation_status
  3. Sort by policy_id ascending

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(120)Customer display name
customer_segmentVARCHAR(40)Customer segmentation label
policies
ColumnTypeDescription
policy_idPKINTUnique policy identifier
customer_idINTReferenced customer identifier
model_statusVARCHAR(30)Policy status in the modeled data
model_transaction_countINTTransaction count recorded by the model
model_total_amountNUMERIC(12,2)Total amount recorded by the model
policy_transactions
ColumnTypeDescription
transaction_idPKINTUnique source transaction identifier
policy_idINTReferenced policy identifier
transaction_typeVARCHAR(30)Type of source transaction
amountNUMERIC(12,2)Transaction amount
Tablescustomerspoliciespolicy_transactions
Interviewer

Your question is Validating Data Models. 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.