Database Design
Relational Database: Postgres.
Reason: Mapping Users and their URLs
- Tables: Users; URLs
- Users table: id, email, passwordhash,
- URL table: id, long url, short url = sharding key, index on short, fk to user_id, created_at
- no duplication
- Creation = strong consistency: a returned short code must be durable and never duplicated.
- Redirects = eventual consistency OK: replica lag might cause a brief transient 404, but never corruption — because you never read stale data that's wrong, it just might not be there yet.