advancedTop 15 Database Design Questions
Design a URL shortener database handling 100,000 URL redirects per second.
urls(id BIGSERIAL, short_code CHAR(8) UNIQUE, original_url TEXT, user_id FK, created_at, expires_at NULLABLE, is_active BOOLEAN) clicks(id BIGSERIAL, url_id FK, clicked_at TIMESTAMPTZ, ip_address INET, user_agent TEXT, referrer TEXT) Index: CREATE UNIQUE INDEX ON urls(short_code) — primary lookup; must be B-Tree for fast equality Partitioning: clicks PARTITION BY RANGE(clicked_at) — high-volume wr
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
Design a URL shortener database handling 100,000 URL redirects per second.