Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Deduplicate Conflicting User Profiles
00:00
5 left

Deduplicate Conflicting User Profiles

MediumSQL · PostgreSQL

Problem

Write a query or processing step to identify duplicate user profiles based on conflicting email and device identifiers.

Treat two profiles as duplicates when they share the same non-null email address or the same non-null device identifier. Return each unordered profile pair once.

Output

  1. One row per duplicate profile pair, ordered by profile_id_1, then profile_id_2.
  2. Columns: profile_id_1, profile_id_2, profile_name_1, profile_name_2, conflict_type, shared_email, and shared_device.
  3. conflict_type must identify an email conflict, device conflict, or both. Use NULL when a shared identifier does not apply.

Schema

user_profiles
ColumnTypeDescription
profile_idPKINTUnique user profile identifier
profile_nameVARCHAR(100)Display name associated with the profile
profile_identifiers
ColumnTypeDescription
profile_idPKINTUser profile identifier
emailVARCHAR(255)Email associated with the profile
device_idVARCHAR(100)Device identifier associated with the profile
Tablesuser_profilesprofile_identifiers
Interviewer

Your question is Deduplicate Conflicting User Profiles. Start with the requirements and the two 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.