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
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response