Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Database Schema for Promo Codes
00:00
5 left

Database Schema for Promo Codes

HardSQL · PostgreSQL

Problem

How would you structure a database schema to track rider promotional codes and their redemption rates across different cities for Uber?

Use the provided normalized tables to calculate monthly redemption performance for January and February 2025. Treat a rider as redeemed when an assignment has at least one redemption with status redeemed.

Output

  1. One row per month, city, and promotional code with at least one assignment.
  2. Columns: month_start, city_name, promo_code, assigned_riders, redeemed_riders, redemption_rate_pct, city_rank, and prior_month_rate_pct.
  3. Rank rows within each month by redemption rate, with ties sharing a rank. Sort by month, city, and promotional code.

Schema

cities
ColumnTypeDescription
city_idPKINTUnique city identifier
city_nameVARCHAR(100)City display name
riders
ColumnTypeDescription
rider_idPKINTUnique rider identifier
rider_nameVARCHAR(100)Rider name
city_idINTRider home city
promo_codes
ColumnTypeDescription
promo_idPKINTUnique promotion identifier
promo_codeVARCHAR(50)Promotional code
descriptionVARCHAR(255)Promotion description
promo_assignments
ColumnTypeDescription
assignment_idPKINTUnique rider promotion assignment
rider_idINTAssigned rider
promo_idINTAssigned promotion
assigned_atTIMESTAMPAssignment timestamp
promo_redemptions
ColumnTypeDescription
redemption_idPKINTUnique redemption event
assignment_idINTRelated promotion assignment
redeemed_atTIMESTAMPRedemption timestamp
statusVARCHAR(20)Redemption status
Tablescitiesriderspromo_codespromo_assignmentspromo_redemptions
Interviewer

Your question is Database Schema for Promo Codes. Start with the requirements and the five 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.