SevyDevy

Design a music streaming database like Spotify

PremiumDatabase designMedium

  • Play history
  • Ordered playlists
  • Many to many

Quick answer

This database design interview question asks you to design a music streaming database like Spotify. Aim for a design that stores data correctly and serves its main queries well, then explain the schema, keys, indexes and trade-offs. Interviewers want to see how you model entities, choose keys and design for the real access patterns.

The problem

Design the database for a music streaming app like Spotify. It holds a catalog of artists, albums and tracks, user playlists (some shared with friends), likes and a recently played list. The hard parts are 2 billion plays a day and exact royalty counts per stream.

Every play is recorded so that rights holders are paid per stream and so the app can show listening stats. Audio files live in object storage.

What must a music streaming database like Spotify do?

  • Catalog browse: Open an artist page with albums and top tracks; open an album with its tracks in order; a track can appear on several albums (compilations).
  • Playlist: Show a playlist's tracks in order; add, remove and reorder tracks; a collaborative playlist is edited by several users.
5 more requirementsUnlock to see all

How well must it do it?

  • Order: An album's track order and a playlist's track order must be stable and exact; the same track may appear in one playlist more than once.
  • Exact counts: Royalty counts must not double-count a play that the client retries after a network error, and must be queryable per track per country per month in under 50 ms.
3 more requirementsUnlock to see all

What scale should you design for?

Use these numbers in your estimates.

The scale numbers unlock with this questionUnlock

Key concepts

  • Play history
  • Ordered playlists
  • Many to many
  • Event partitioning
  • Royalty counts
  • Catalog modeling

How you’ll practise

6 short steps · save and come back any time
  1. Access patterns
  2. Entities
  3. Schema
  4. Indexes and queries
  5. Scale and consistency
  6. Wrap-up

Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.

What do interviewers look for?

In any database design round.

  • Lists the entities and how they relate before writing tables
  • Designs the schema around the main access patterns
  • Chooses primary keys, foreign keys and indexes with reasons
  • Explains where to normalise and where to denormalise
  • Considers integrity, transactions and concurrent writes
  • Plans for growth: partitioning, archiving and migrations

Questions people ask about this interview question

Which design type is this question?
It is a database design question. You design a music streaming database like Spotify and explain your choices the way you would in an interview.
Is this question asked at entry level?
It is marked Medium. Entry-level engineers can practise it, but it expects you to reason about requirements and trade-offs, not only list components.
What should I cover first?
Start with the entities and the main queries the database must answer. Agree on scope with the interviewer before you design anything.
Can I practise it for free?
It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.

Related questions

Updated · Written by the SevyDevy team

Premium questionSign up free, then unlock it