Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Data Clearing and Modeling
00:00
5 left

Data Clearing and Modeling

HardSQL · PostgreSQL

Problem

Explain how you would approach data clearing and modeling for a reality-based problem scenario.

Using the provided tables, write a PostgreSQL query that excludes invalid records, resolves related creator and event information, and summarizes valid activity. Treat records with missing required identifiers or timestamps, negative watch time, inactive event types, or unmatched references as invalid. Do not exclude valid events solely because watch time is NULL.

Output

  1. One row per creator and active event category.
  2. Return creator_id, creator_name, event_category, event_count, total_watch_seconds, and category_rank.
  3. Rank categories within each creator by total watch time descending, with ties sharing a rank. Sort by creator_id, category_rank, and event_category.

Schema

creators
ColumnTypeDescription
creator_idPKINTUnique creator identifier
creator_nameVARCHAR(100)Creator display name
event_types
ColumnTypeDescription
event_type_idPKINTUnique event type identifier
event_nameVARCHAR(50)Raw event name
event_categoryVARCHAR(50)Normalized event category
is_activeBOOLEANWhether the event type is currently valid
raw_reality_events
ColumnTypeDescription
event_idPKINTUnique raw event identifier
creator_idINTReferenced creator identifier
event_type_idINTReferenced event type identifier
event_tsTIMESTAMPTimestamp when the event occurred
watch_secondsINTObserved watch duration in seconds
Tablesraw_reality_eventscreatorsevent_types
Interviewer

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