Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Build Compliant Marketing Data Pipelines
00:00
5 left

Build Compliant Marketing Data Pipelines

HardSQL · PostgreSQL

Problem

How would you approach building a robust data pipeline to ensure data quality, compliance, and privacy controls in marketing operations?

For the supplied marketing event data, write a PostgreSQL query that identifies records requiring quarantine before activation or reporting. Apply the stated validity, consent, campaign, duplicate, and suppression rules without exposing raw email addresses.

Output

  1. One row per marketing event, ordered by event_date, then event_id.
  2. Return event_id, event_date, user_id, channel, email_is_valid, outcome, and issue_codes.
  3. Include all events. outcome must be eligible or quarantine; use none when no issue exists.

Schema

marketing_events
ColumnTypeDescription
event_idPKINTUnique marketing event identifier
user_idVARCHAR(20)Pseudonymous user identifier
event_timeTIMESTAMPTimestamp when the marketing event occurred
channelVARCHAR(20)Marketing activation channel
campaign_idVARCHAR(20)Campaign associated with the event
emailVARCHAR(255)Captured email value, used only for validation
consent_records
ColumnTypeDescription
consent_idPKINTUnique consent record identifier
user_idVARCHAR(20)Pseudonymous user identifier
consent_statusVARCHAR(20)Consent state at grant time
granted_atTIMESTAMPTime the consent record became effective
revoked_atTIMESTAMPTime consent was revoked
campaign_registry
ColumnTypeDescription
campaign_idPKVARCHAR(20)Registered campaign identifier
campaign_nameVARCHAR(100)Campaign display name
active_fromTIMESTAMPCampaign activation timestamp
active_toTIMESTAMPCampaign deactivation timestamp
suppression_list
ColumnTypeDescription
suppression_idPKINTUnique suppression record identifier
user_idVARCHAR(20)Pseudonymous user identifier
channelVARCHAR(20)Suppressed channel, or all channels when null
starts_atTIMESTAMPSuppression start timestamp
ends_atTIMESTAMPSuppression end timestamp
Tablesmarketing_eventsconsent_recordscampaign_registrysuppression_list
Interviewer

Your question is Build Compliant Marketing Data Pipelines. Start with the requirements and the four 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.