advancedTop 15 Database Design Questions

Design a social media platform database: users, posts, follows, likes, comments.

users(id BIGSERIAL PK, username UNIQUE, email UNIQUE, created_at) posts(id BIGSERIAL, user_id FK, content TEXT, media_urls JSONB, created_at) — partition by month follows(follower_id FK, following_id FK, created_at, PRIMARY KEY(follower_id, following_id)) likes(user_id FK, post_id FK, created_at, PRIMARY KEY(user_id, post_id)) — no duplicates comments(id, post_id FK, user_id FK, content, parent_id

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.

Design a social media platform database: users, posts, follows, likes, comments.

Next Step

Continue to Design a time-series sensor data database for 10,000 IoT sensors reporting every second.← Back to all SQL questions