-- Do NOT RUN

--artist extraction
INSERT INTO Artist(id, name, description)
select ag.artistid, ag.name, "No description available" from artists_group ag where ag.name in
(
	"Taylor Swift",
	"Ed Sheeran",
	"IU",
	"The Script",
	"Maroon 5",
	"ZAYN",
	"Khalid",
	"Charlie Puth",
	"Kygo",
	"Akon",
	"Imagine Dragons",
	"P!ink",
	"BTS",
	"Calvin Harris",
	"One Direction",
	"Kendrick Lamar",
	"Niall Horan",
	"Avicii",
	"LANY",
	"Halsey",
	"Jason Derulo",
	"ClariS",
	"Post Malone",
	"5 Seconds of Summer",
	"21 Savage",
	"Adam Lambert",
	"Adele",
	"Alan Walker",
	"Alessia Cara",
	"Alesso",
	"American Authors",
	"Andy Grammer",
	"Ariana Grande",
	"Backstreet Boys",
	"Bastille",
	"Bebe Rexha",
	"Big Sean",
	"Bruno Mars",
	"Calvin Harris",
	"Camila Cabello",
	"Cardiknox",
	"The Chainsmokers",
	"Charlie Puth",
	"Chris Brown",
	"Coldplay",
	"David Guetta",
	"Dawin",
	"Daya",
	"DJ Khaled",
	"DNCE",
	"Drake",
	"Echosmith",
	"Ellie Goulding",
	"Fall Out Boy",
	"Fetty Wap",
	"Fifth Harmony",
	"Flo Rida",
	"Galantis",
	"Hinder",
	"Jay Sean",
	"Imagine Dragons",
	"Jason Derulo",
	"Jason Mraz",
	"Jessie J",
	"Jonas Blue",
	"Justin Bieber",
	"Justin Timberlake",
	"Katy Perry",
	"Khalid",
	"Lifehouse",
	"Lorde",
	"Maroon 5",
	"Martin Garrix",
	"Meghan Trainor",
	"Miley Cyrus",
	"Moderat",
	"Nelly",
	"Ne-Yo",
	"Nicki Minaj",
	"Owl City",
	"Rihanna",
	"Rixton",
	"Sam Smith",
	"The Script",
	"Secondhand Serenade",
	"Selena Gomez",
	"Shawn Mendes",
	"Sia",
	"Starship",
	"Troye Sivan",
	"Twenty One Pilots",
	"Wiz Khalifa",
	"Zara Larsson",
	"Zedd"
);

--album extraction
INSERT INTO Album(id, album_name, year, artist_id)
select distinct tg.id, name, year, (select artistid from torrents_artists where groupid=tg.id order by importance asc limit 1) as artistidv 
from torrents_group tg join torrents_artists ta on ta.groupid = tg.id
where (select artistid from torrents_artists where groupid=tg.id order by importance asc limit 1)
 in (select id from artist) and (ta.artistid in (select id from artist)) and tg.releasetype=1 order by tg.id;

--song extraction
INSERT INTO Song(song_name, genre, artist_id, album_id)
select (select filelist from torrents where groupid=album.id order by time desc limit 1), tg.taglist , artist.id, album.id
from artist join album on album.artist_id = artist.id join torrents_group tg on tg.id = album.id;

