Social Media Platform — DataFlow Project
Social Media Platform — DataFlow Project: free step-by-step lesson with examples, common mistakes, and interview tips — part of MySQL Tutorial on Toolliyo Academy.
On this page
MySQL Tutorial · Lesson 92 of 100
Social Media Platform
Basics ✓ → Advanced
Advanced · 2 — Production · ~10 min · MySQL — Real-World Projects
What is this?
Social schema models users, posts, follows, likes, comments — heavy read feeds and write bursts on posts/likes. MySQL holds relational core; caches often front hot feeds.
Why should you care?
Instagram-style app still needs consistent likes count and follow graph — MySQL with good indexes beats document store for “who follows whom” JOINs.
See it live — copy this example
Run in MySQL Workbench or the mysql CLI.
CREATE TABLE posts (
post_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
author_id INT UNSIGNED NOT NULL,
body TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE follows (
follower_id INT UNSIGNED NOT NULL,
followee_id INT UNSIGNED NOT NULL,
PRIMARY KEY (follower_id, followee_id)
);
SELECT p.post_id, p.body
FROM posts p
JOIN follows f ON f.followee_id = p.author_id
WHERE f.follower_id = 7
ORDER BY p.created_at DESC
LIMIT 20;
What happened?
- Feed query: posts from people user 7 follows.
- Composite PK on follows prevents duplicate follows.
- Index (followee_id, created_at) on posts optimizes feed in production.
Practice next
- Create posts and follows in DataFlow.
- Insert users, follows, posts.
- Run feed query for follower_id 7.
- Add likes table and COUNT subquery on post.
- Pagination with keyset (post_id < ?) not deep OFFSET.
Remember
Follow graph = junction with composite PK. Feed = JOIN follows to posts + ORDER BY time. Index for follower-centric queries.
DataFlow social module
Campus app prototype uses this feed query with Redis cache top 100 posts.
Outcome: MySQL source of truth; cache refreshes on TTL.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!