๐ Social Media SQL Analytics Project
A fully relational SQL project that simulates a real social media platform with users, posts, likes, comments, followers, messages, and hashtags.
Built with PostgreSQL and designed for advanced SQL analytics and portfolio demonstration.
๐ Project Overview
This project models the core features of platforms like Instagram or Twitter using pure SQL.
You can perform:
User analytics
Engagement analysis
Ranking & leaderboards
Follower network analysis
Post performance insights
Window functions
CTE-based queries
Data relationships analysis
Everything is designed to match real industry database standards.
๐งฑ Database Schema
This database contains the following tables:
Table Description
users User profiles and account info
posts User posts with optional images
likes Likes on posts
comments User comments on posts
follows Followerโfollowing relationships
hashtags Hashtags used on posts
post_hashtags Mapping posts โ hashtags
messages Direct messages between users
The schema includes foreign keys, CASCADE deletes, unique constraints, and primary keys.
๐ All table definitions are in:
schema/create_tables.sql
๐ฅ Sample Data
The project includes fully realistic sample data:
5 users
5 posts
Likes, comments, followers
Non-conflicting inserts
Clean and simple structure
๐ Sample data file:
data/sample_inserts.sql
You can load the data by running this script in pgAdmin or psql.
๐ Analytics & SQL Queries
The project contains 20 advanced SQL queries, including:
โ Most liked posts
โ Posts with highest comments
โ Top influencers
โ Mutual followers
โ User engagement rate
โ Most active users
โ Window functions: RANK()
โ Users with no posts
โ Likes and comments received
โ Comment ranking
โ Post/follower ratio
๐ Analytics queries are in:
queries/analytics_queries.sql
These queries demonstrate real-world SQL skills useful for interviews and data roles.
๐ Tech Stack
PostgreSQL 16+
pgAdmin 4
Pure SQL (no backend or Python required)
๐ง How to Run
Create a new database:
CREATE DATABASE social_media_db;
Run table schema:
schema/create_tables.sql
Insert sample data:
data/sample_inserts.sql
Run analytics:
queries/analytics_queries.sql
๐ Why This Project is Valuable
This project demonstrates:
Advanced SQL skills
Database design knowledge
Real social media relational modeling
Analytical thinking
Clean GitHub project structure
Interview-ready queries
Perfect for showcasing SQL + database skills in your portfolio.
๐จโ๐ป Created By
Akshay R
(SQL, Python & Data Analytics Student)