Skip to content

A complete SQL social media analytics project using PostgreSQL. Includes schema, sample data, analytics queries, and ER diagram.

Notifications You must be signed in to change notification settings

akshayremesh7/Social-Media-SQL-Analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š 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)

About

A complete SQL social media analytics project using PostgreSQL. Includes schema, sample data, analytics queries, and ER diagram.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published