This project analyzes social media data using SQL to understand user activity, post performance, likes, comments, shares, and engagement.
The project demonstrates how SQL can be used to extract meaningful insights from social media data.
- Analyze user activity on social media.
- Find posts with the highest number of likes.
- Calculate engagement rates.
- Identify the most active users.
- Analyze likes, comments, and shares.
- Find popular posts and content.
- Practice SQL concepts used in real-world data analysis.
- MySQL
- SQL
- MySQL Workbench
social-media-data-analysis/
│
├── database.sql
├── tables.sql
├── insert_data.sql
├── analysis_queries.sql
├── screenshots/
│ ├── database.png
│ ├── query1.png
│ └── results.png
│
└── README.md
Stores information about social media users.
| Column | Description |
|---|---|
| user_id | Unique user ID |
| username | User name |
| User email | |
| created_at | Account creation date |
Stores information about posts created by users.
| Column | Description |
|---|---|
| post_id | Unique post ID |
| user_id | ID of the user who created the post |
| content | Post content |
| created_at | Post creation date |
Stores likes received by posts.
| Column | Description |
|---|---|
| like_id | Unique like ID |
| post_id | ID of the liked post |
| user_id | ID of the user who liked the post |
Stores comments made on posts.
| Column | Description |
|---|---|
| comment_id | Unique comment ID |
| post_id | ID of the post |
| user_id | ID of the commenter |
| comment_text | Comment content |
| created_at | Comment date |
Stores information about shared posts.
| Column | Description |
|---|---|
| share_id | Unique share ID |
| post_id | ID of the shared post |
| user_id | ID of the user who shared the post |
| shared_at | Share date |
The project includes SQL queries to find:
- Total number of users.
- Total number of posts.
- Most active users.
- Posts with the maximum likes.
- Posts with the maximum comments.
- Most shared posts.
- Number of likes received by each post.
- Number of comments received by each post.
- User engagement.
- Engagement rate of posts.
- Top-performing posts.
- Users who created the most posts.
Engagement rate can be calculated using:
Engagement Rate =
(Likes + Comments + Shares) / Total Followers × 100
The exact formula can be modified depending on the available data.
- SELECT
- WHERE
- ORDER BY
- GROUP BY
- HAVING
- COUNT()
- AVG()
- MAX()
- INNER JOIN
- LEFT JOIN
- Subqueries
- Aggregate Functions
How to Run the Project
Run:
database.sqlRun:
tables.sqlRun:
insert_data.sqlRun:
analysis_queries.sql