๐ SQL Project Series #14
Social Media Analytics ๐ฑ
Analyze users, posts, likes, comments, shares, and engagement metrics using SQL to understand user behavior and platform growth.
๐ฏ Business Objectives
โ
Analyze user growth
โ
Measure content engagement
โ
Track active users
โ
Identify trending posts
โ
Analyze creator performance
โ
Monitor user retention
โ
Measure platform activity
โ
Build engagement dashboards
๐ Step 1: Create Database
CREATE DATABASE social_media_db;
USE social_media_db;
๐ Step 2: Create Users Table
CREATE TABLE users (
user_id INT PRIMARY KEY,
user_name VARCHAR(100),
city VARCHAR(50),
join_date DATE
);
๐ Step 3: Create Posts Table
CREATE TABLE posts (
post_id INT PRIMARY KEY,
user_id INT,
post_date DATE,
content_type VARCHAR(30),
views INT,
FOREIGN KEY (user_id)
REFERENCES users(user_id)
);
๐ Step 4: Create Engagement Table
CREATE TABLE engagement (
engagement_id INT PRIMARY KEY,
post_id INT,
likes INT,
comments INT,
shares INT,
FOREIGN KEY (post_id)
REFERENCES posts(post_id)
);
๐ Step 5: Insert Sample Users
INSERT INTO users VALUES
(1,'Rahul','Mumbai','2024-01-10'),
(2,'Priya','Delhi','2024-02-15'),
(3,'Amit','Pune','2024-03-08'),
(4,'Sneha','Bangalore','2024-04-05'),
(5,'Rohan','Hyderabad','2024-05-12');
๐ Step 6: Insert Sample Posts
INSERT INTO posts VALUES
(101,1,'2025-01-05','Image',1200),
(102,2,'2025-01-06','Video',5400),
(103,3,'2025-01-06','Reel',8900),
(104,4,'2025-01-07','Image',2500),
(105,5,'2025-01-08','Video',6100);
๐ Step 7: Insert Sample Engagement
INSERT INTO engagement VALUES
(1,101,180,22,15),
(2,102,520,84,60),
(3,103,950,145,110),
(4,104,240,35,20),
(5,105,610,92,70);
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ INNER JOIN
โ LEFT JOIN
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Window Functions
โ CTEs
โ Date Functions
๐ Business KPIs You Can Build
๐ Total Users
๐ New Users by Month
๐ Daily Active Users (DAU)
๐ Monthly Active Users (MAU)
๐ Total Posts
๐ Posts by Content Type
๐ Total Views
๐ Average Views per Post
๐ Total Likes
๐ Total Comments
๐ Total Shares
๐ Engagement Rate
๐ Average Engagement per User
๐ Top 10 Creators
๐ Most Viewed Posts
๐ Most Liked Posts
๐ Most Shared Posts
๐ User Retention Rate
๐ Content Performance by Type
๐ City-wise User Distribution
๐ Posting Trend by Month
๐ Viral Content Analysis
๐ Creator Growth Analysis
๐ Platform Growth Dashboard
๐ Executive Social Media Dashboard
This project reflects real-world SQL analysis performed by Product Analysts, Growth Analysts, Marketing Analysts, and Business Intelligence teams at companies like Instagram, Facebook, LinkedIn, X, and YouTube.
๐ก Double Tap โค๏ธ For More
Post #2612
3.42K
- โค 14
- ๐ 1