Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ERD Diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25,306 changes: 25,306 additions & 0 deletions Grammy Award Nominees and Winners 1958-2024.csv

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions analysis_queries.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
USE MusicAnalyticsDB;

-- Which are the most popular tracks in the Spotify Top 50, and who performs them?
SELECT
g.genre_name,
COUNT(*) AS tracks,
ROUND(AVG(t.popularity),2) AS average_popularity
FROM Tracks t
JOIN Genres g
ON t.genre_id = g.genre_id
GROUP BY g.genre_name
ORDER BY average_popularity DESC;

-- Because many genres in our dataset only have one song, we will filter out genres represented by only one track.
SELECT
g.genre_name,
COUNT(*) AS tracks,
ROUND(AVG(t.popularity),2) AS average_popularity
FROM Tracks t
JOIN Genres g
ON t.genre_id = g.genre_id
GROUP BY g.genre_name
HAVING COUNT(*) >= 2
ORDER BY average_popularity DESC;

-- Which genres have the highest average popularity among the Spotify Top 50 tracks?
SELECT
g.genre_name,
COUNT(*) AS number_of_tracks,
ROUND(AVG(t.popularity),2) AS average_popularity
FROM Tracks t
JOIN Genres g
ON t.genre_id = g.genre_id
GROUP BY g.genre_name
ORDER BY average_popularity DESC;

-- What are the average audio characteristics of highly popular songs?
SELECT
ROUND(AVG(energy),2) AS avg_energy,
ROUND(AVG(danceability),2) AS avg_danceability,
ROUND(AVG(acousticness),2) AS avg_acousticness,
ROUND(AVG(speechiness),2) AS avg_speechiness
FROM Audio_Features af
JOIN Tracks t
ON af.track_id = t.track_id
WHERE t.popularity >= 90;

-- Which songs perform better than the average popularity of the Spotify Top 50?
SELECT
track_name,
popularity
FROM Tracks
WHERE popularity >
(
SELECT AVG(popularity)
FROM Tracks
)
ORDER BY popularity DESC;

-- Which Grammy-nominated artists also achieve high popularity on Spotify?
SELECT
a.artist_name,
COUNT(DISTINCT gn.nomination_id) AS nominations,
ROUND(AVG(t.popularity),2) AS avg_popularity
FROM Artists a
JOIN Grammy_Nominations gn
ON a.artist_id = gn.artist_id
JOIN Tracks t
ON a.artist_id = t.artist_id
GROUP BY a.artist_name
ORDER BY nominations DESC, avg_popularity DESC;

-- What are the average audio characteristics of the Spotify Top 50 songs?
SELECT
ROUND(AVG(bpm),2) AS bpm,
ROUND(AVG(energy),2) AS energy,
ROUND(AVG(danceability),2) AS danceability,
ROUND(AVG(acousticness),2) AS acousticness,
ROUND(AVG(speechiness),2) AS speechiness,
ROUND(AVG(valence),2) AS valence
FROM Audio_Features;

39 changes: 39 additions & 0 deletions artists.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
artist_id,artist_name
1,Shawn Mendes
2,Anuel AA
3,Ariana Grande
4,Ed Sheeran
5,Post Malone
6,Lil Tecca
7,Sam Smith
8,Lil Nas X
9,Billie Eilish
10,Bad Bunny
11,DJ Snake
12,Lewis Capaldi
13,Sech
14,Drake
15,Chris Brown
16,J Balvin
17,Y2K
18,Lizzo
19,MEDUZA
20,Jhay Cortez
21,Lunay
22,Tones and I
23,Ali Gatie
24,Daddy Yankee
25,The Chainsmokers
26,Maluma
27,Young Thug
28,Katy Perry
29,Martin Garrix
30,Jonas Brothers
31,Lauv
32,Kygo
33,Taylor Swift
34,Lady Gaga
35,Khalid
36,ROSALÍA
37,Marshmello
38,Nicky Jam
51 changes: 51 additions & 0 deletions audio_features.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
track_id,bpm,energy,danceability,loudness_db,liveness,valence,length,acousticness,speechiness
1,117,55,76,-6,8,75,191,4,3
2,105,81,79,-4,8,61,302,8,9
3,190,80,40,-4,16,70,186,12,46
4,93,65,64,-8,8,55,198,12,19
5,150,65,58,-4,11,18,175,45,7
6,102,68,80,-5,9,84,220,9,4
7,180,64,75,-6,7,23,131,2,29
8,111,68,48,-5,8,35,202,15,9
9,136,62,88,-6,11,64,157,5,10
10,135,43,70,-11,10,56,194,33,38
11,176,62,61,-5,24,24,251,60,31
12,96,71,82,-4,15,38,185,28,7
13,110,41,50,-6,11,45,182,75,3
14,176,79,73,-2,6,76,288,7,20
15,101,50,83,-4,12,10,205,10,5
16,93,45,70,-7,16,14,261,12,15
17,176,65,75,-6,11,43,243,15,32
18,90,48,76,-6,7,91,158,56,5
19,130,39,84,-8,14,50,161,18,8
20,158,62,72,-3,12,41,173,11,11
21,124,74,68,-7,7,63,153,4,3
22,154,59,70,-6,12,48,115,34,8
23,92,79,81,-4,9,58,309,14,7
24,92,78,80,-4,44,80,266,36,4
25,135,45,67,-11,12,68,195,25,30
26,124,82,69,-4,13,87,191,49,6
27,98,59,82,-6,18,54,210,69,10
28,96,46,73,-7,19,40,213,37,3
29,94,86,74,-3,6,66,193,11,6
30,93,79,64,-4,36,94,222,3,25
31,85,51,29,-8,10,36,210,12,4
32,140,32,78,-11,9,33,179,59,33
33,96,71,78,-5,9,68,176,22,28
34,98,59,80,-7,13,18,200,2,15
35,100,88,77,-5,32,39,224,19,6
36,114,72,66,-7,14,32,164,18,6
37,176,70,75,-5,11,62,226,14,34
38,152,82,72,-5,36,91,162,13,5
39,138,73,84,-5,11,95,181,4,6
40,95,56,81,-6,6,68,199,48,7
41,104,68,69,-7,10,40,228,2,3
42,85,68,77,-6,7,73,171,1,5
43,96,39,57,-6,23,32,216,37,3
44,136,40,90,-9,6,35,198,5,13
45,98,69,88,-4,5,75,162,39,12
46,88,62,66,-2,58,44,182,7,5
47,176,75,67,-4,8,80,202,24,6
48,100,79,69,-3,17,67,214,19,5
49,104,70,59,-6,41,50,218,23,3
50,95,79,75,-6,7,61,206,21,12
30 changes: 30 additions & 0 deletions create_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import mysql.connector
from pathlib import Path
from getpass import getpass

password = getpass("MySQL password: ")
BASE_DIR = Path(__file__).resolve().parent

connection = mysql.connector.connect(
host="localhost",
user="root",
password=password
)

cursor = connection.cursor()

with open(BASE_DIR / "schema.sql", "r") as file:
sql_script = file.read()

# Execute each SQL statement
for statement in sql_script.split(";"):
statement = statement.strip()
if statement:
cursor.execute(statement)

connection.commit()

cursor.close()
connection.close()

print("Database and tables created successfully!")
Loading