Instagram User Analytics
Instagram User Analytics
As we proceed above, I created a database by the name Instagram ig_clone. The database
consists of total 7 tables.
1. USER TABLE
2. PHOTOS TABLE
3. COMMENTS TABLE
4. LIKES TABLE
5. FOLLOWS TABLE
6. TAGS TABLE
7. PHOTO-TAGS TABLE
The user table consists of 3 attributes, id being the primary. The photos table has its own
primary key by the name ID. Different tables were connected to it with the help of Foreign
key such as likes, comments, photo-tags and tags..There is a table called follows, which
stores the followers and the following ID.
Approach towards the project was fairly simple, I cloned the project and executed the
commands as given in the data set by the team. After that I wrote all the queries needed to
find out the solutions as asked in the questions.
Tech stack used was SQL (Ver 8.0.32)- downloaded it from link provided in the document
and then after that downloaded the SQL WORKBENCH(Ver 8.0.32)- it provides a visual
console to easily administer the MySQL environments and gain better visibility into the
databases.
DETAILED REPORT
A) MARKETING- The team wants to launch some campaigns, and they need some help
with following questions-
1. Rewarding the most loyal users: It shows the people who have been using the
platform for the longest time.
Task – Find the 5 oldest users of the Instagram from the database provided by
the team.
Stack used – SQL
QUERY
SELECT *
FROM users
ORDER BY created_at
LIMIT 5;
SELECT – it tell your database that you want to select data.
FROM users tells the database to select data from the user table.
(*) tells the database that you want to see all columns in this table.
ORDER BY- after this expression, simply specify a column on which the data will
be sorted.
LIMIT n - returns the first n rows from the result. This is much more efficient than
returning all the data from the database.
RESULT-
Id username created_at
80 Darby_Herzog 2016-05-06 00:14:21
67 Emilio_Bernier52 2016-05-06 13:04:30
63 Elenor88 2016-05-08 01:30:41
95 Nicole71 2016-05-09 17:30:22
38 Jordyn.Jacobson2 2016-05-14 07:56:26
LEFT JOIN works in the following way: it returns all rows from the left table (the
first table in the query) plus all matching rows from the right table (the second
table in the query).
RESULT –
username
Aniya_Hackett
Bartholome.Bernhard
Bethany20
Darby_Herzog
David.Osinski47
Duane60
Esmeralda.Mraz57
Esther.Zulauf61
Franco_Keebler64
Hulda.Macejkovic
Jaclyn81
Janelle.Nikolaus81
Jessyca_West
Julien_Schmidt
Kasandra_Homenick
Leslie67
Linnea59
Maxwell.Halvorson
Mckenna17
Mike.Auer39
Morgan.Kassulke
Nia_Haag
Ollie_Ledner37
Pearl7
Rocio33
Tierra.Trantow
SELECT
username,
photos.id,
photos.image_url,
COUNT(*) AS total
FROM photos
INNER JOIN likes
ON likes.photo_id = photos.id
INNER JOIN users
ON photos.user_id = users.id
GROUP BY photos.id
ORDER BY total DESC
LIMIT 1;
INNER JOIN (or JOIN, for short) only shows those rows from the two tables
where there is a match between the columns. In other words, you can only see
those pieces of equipment which have a room assigned and vice versa
RESULT –
Username id image_url total
Zack_Kemmer93 145 https://jarret.name 48
Result shows the user whose photo is most liked on the instagram.
4. HASHTAG RESEARCHING:
Hashtag helps the user to reach to wide range of people. It is used to draw
attention ,organise, promote and connect.
Task- to identify the top 5 most commonly used hashtags on instagram.
SQL QUERY –
SELECT tags.tag_name,
COUNT(*) AS total
FROM photo_tags
JOIN tags
ON photo_tags.tag_id = tags.id
GROUP BY tags.id
ORDER BY total DESC
LIMIT 5;
COUNT()- function returns the number of rows that matches the specific criteria.
AS- new keyword AS and we put the new name after it (person_id). We can
repeat this process with every column.
AS- The new name is just an alias, which means it's temporary and doesn't
change the actual column name in the database. It only influences the way the
column is shown in the result of the specific query. This technique is often used
when there are a few columns with the same name coming from different tables.
Normally, when SQL displays columns in the result, there is no information about
the table that a specific column is part of.
RESULT-
tag_name total
smile 59
beach 42
party 39
fun 38
concert 24
5. LAUNCH AD CAMPAIGN
TASK – To find out the day of week when most users register’s on Instagram.
SQL QUERY
SELECT
DAYNAME(created_at) AS day,
COUNT(*) AS total
FROM users
GROUP BY day
ORDER BY total DESC
LIMIT 2;
RESULT
day total
Thursday 16
Sunday 16
The query result shows two days of the week when the users register mostly
According to me the most suitable day to launch the ad campaign would be
Sunday because users mostly have leisure time on Sunday and more interaction
would happen on Sunday.
B. INVESTER MATRICS
6. USER ENGAGEMENT- Investers want to know that instagram is not becoming redundant
like facebook, so they want to check the frequency of how much the users are engaging on
the platform.
Task – to provide how many times an average user post on instagram.
SQL QUERY –
RESULT-
avg
2.5700
2. BOTS& FAKE ACCOUNTS- It is reported that there are lot of bots ans fake accounts on the
platform. The investors wants to know if there are fake and dummy accounts.
Task – To Provide data on users(bots) who have liked every single photo on the site(normal
user would not be able to do this).
SQL QUERY-
SELECT username,
Count(*) AS num_likes
FROM users
ON users.id = likes.user_id
GROUP BY likes.user_id
FROM photos);
RESULT- From the query I found out there 13 fake accounts on the instagram.
username num_likes
Aniya_Hackett 257
Bethany20 257
Duane60 257
Jaclyn81 257
Janelle.Nikolaus81 257
Julien_Schmidt 257
Leslie67 257
Maxwell.Halvorson 257
Mckenna17 257
Mike.Auer39 257
Nia_Haag 257
Ollie_Ledner37 257
Rocio33 257
OVERALL RESULT – While doing this project I found out so many important terms of MYSQL
that helps in solving complex problems irrespective of how large the database is. I got to
learn about using sql and whereabouts of sql workbench and i believe it will help me in
future a lot. I have provided the solutions to every questions asked and i believe they are
correct to the best of my knowledge and it solves all the query.
THANKYOU.