SlideShare a Scribd company logo
1 of 4
Thousand Song Database Fix
1)
Afterreviewingthe database thatwaspresentedtome Icame across a numberof problems
associatedwithunorganizeddata.Irealizedthere isMore thanone song inan album;whichwouldbe
more or lessaccurate formost albumspublished.However,beingin anorganizeddatabase byhaving
the currentlylistedsongsaswell asalbumsrepresentmanyproblems.If youwere tolookspecificallyfor
a song butonlyrecall the albumtitle;bylookingupthe albumtitle youwill come acrossatleasttento
twelve songs,youwouldneedtosiftthroughtofindyourspecificone.Justaswell if youfeltthe needto
take off the albumtitle butperhapskeepafew goodsongs youenjoyedunfortunatelythe wayMySQL
worksyouwouldundoubtedlyerase the album’stitle andsongsassociatedwithit.Finally,there are
quite a numberof columnsthatdescribe the songas well asa numberof columnsthatdescribe the
album.Thisby itself isafundamentallyflawfororganizeddata;byhavingmultipleentitiesand
attributestogetherinone table makescategorizingandupdatingadatabase notonlydifficultbutin
some casesimpossible.
Anotherproblemsimilartothe above conflictinvolvesmore thanone albumcreatedbyan
artist.Thisdatabase showsmultiple albumswiththe same artists.Fairlycommonforanartistto have
more than one albumhoweverincreatinganorganizeddatabase thisisalsoafundamentallyflaw.If you
wantedtosearch for a specificsongtitle butonlyrecall the artistswhocreatedthe song;ratherthan a
narrow resultyoursearch parameters,youwouldbe presentedwithavastamountof songtitlesand
albums.Bycreatingseparate tablessortingoutartistand songtitle findingaspecificsongorartist would
make the resultmuchmore narrowand better.
Andfinallythe genre columnisveryvastandwithtwothousandsongsonlya few genresare
present.Thisisa massive problemthatcancreate terrible outcomesif notproperlyfixed.If youdecided
one day youare sickof rock musicand decide todelete itfromyourdatabase.Half of yourdatabase is
labeledgenre of rockmusic;youwill notonlyloose half yoursongsbutif throughthisdelete there were
a fewsongsevenif labeledrockyouenjoyed;well now itiscompletelygone.Furthermore,lookingfor
specificsongsorartistsbut usingthe genre wouldbe anightmare inthe results;consideringsomanyare
of differentgenres.Bymakingaseparate columnandusingprimaryand foreignkeysIcan make this
disasterintoa fixable anduseable searchoption;butalsoallow formore genrestobe addedwithease.
2)
ThisdiagramI have createdshowswhat the new database will looklikeaswell asrelationships
betweenthe columns. Bymakingseparate attribute columnswe canmake queuingandupdating very
easy.
The main reasonI chose thisdiagramissimplyupdating,adding,searching,fixingamongother
actionsmakesthis veryeasy.Knowingeverysongcanhave differentgenres,albumsandartistsmake
not onlya 1 to manyrelationshipsonthe othertablesbutalsoallowsforeignkeystobe placedinthe
songtable fromall othertables.Bymakingprimarykeysthatare allowingeachcolumnnumberedin
each table Iam allowingeachbitof informationlabeledwithaspecificIDof itsown.Havingthat makes
all the informationinthisdatabase unique,easilyidentifiable andusefulforall the actionsmentioned
above.
Song
song_id (primary key)
song_title
time_mins
number_of_plays
artist_id (foreign key)
album_id (foreign key)
Artist
artist_id (primary_key)
name
Album
album_id (primary key)
album_title
year
genre
3)
CREATE TABLE Song
( song_IdintNOT NULL Auto_increment,title varchar(50) NOTNULL, length_minstime(5),
number_of_playsint(3),PRIMARYKEY(song_Id) )
AlterTable Song
ADD columnartist_idintnotnull
AlterTable song
Addcolumnalbum_idintnotnull
CREATE TABLE Artist
( artist_idintNOT null Auto_Increment,name varchar(100),PRIMARYKEY (artist_id) )
CREATE TABLE Album
( album_idintNOTnull Auto_increment,title varchar(100),yearint(4),genre varchar(4), PRIMARYKEY
(album_id) )
4)
INSERT INTOSongVALUES ("heartbreak","3:20","10",NOTnull)
INSERT INTOArtistVALUES("RockyMountaint",NOTnull)
INSERT INTOAlbumVALUES("Heavenful", 2012, rock, NOT null)
5)
INSERT INTOSong(title,time_mins,number_of_plays) SELECTsong,time,playsFROMmusic
INSERT INTOArtist(name) SELECTdistinctartistFROMmusic
INSERT INTOAlbum(title,year,genre) SELECTdistinctalbum, year,genre FROMmusic
Update Song SetSong.album_id=(Selectdistinctalbum_idfromAlbum, musicwhereAlbum.album_id=
music.albumandSong.title =music.song)
Update Song SetSong.artist_id=(Selectdistinctartiis_idfromArtist,musicwhere Artist.name =
music.artistandSong.song_id=music.song)
Final project 201

More Related Content

Viewers also liked

Viewers also liked (6)

Analysis of a professional contents page
Analysis of a professional contents pageAnalysis of a professional contents page
Analysis of a professional contents page
 
Step by step process of my school magazine
Step by step process of my school magazineStep by step process of my school magazine
Step by step process of my school magazine
 
Evaluation of college magazine
Evaluation of college magazineEvaluation of college magazine
Evaluation of college magazine
 
Codes and conventions of a music magazine
Codes and conventions of a music magazineCodes and conventions of a music magazine
Codes and conventions of a music magazine
 
Production plan
Production planProduction plan
Production plan
 
Kerrang!media pack2016
Kerrang!media pack2016Kerrang!media pack2016
Kerrang!media pack2016
 

Final project 201

  • 1. Thousand Song Database Fix 1) Afterreviewingthe database thatwaspresentedtome Icame across a numberof problems associatedwithunorganizeddata.Irealizedthere isMore thanone song inan album;whichwouldbe more or lessaccurate formost albumspublished.However,beingin anorganizeddatabase byhaving the currentlylistedsongsaswell asalbumsrepresentmanyproblems.If youwere tolookspecificallyfor a song butonlyrecall the albumtitle;bylookingupthe albumtitle youwill come acrossatleasttento twelve songs,youwouldneedtosiftthroughtofindyourspecificone.Justaswell if youfeltthe needto take off the albumtitle butperhapskeepafew goodsongs youenjoyedunfortunatelythe wayMySQL worksyouwouldundoubtedlyerase the album’stitle andsongsassociatedwithit.Finally,there are quite a numberof columnsthatdescribe the songas well asa numberof columnsthatdescribe the album.Thisby itself isafundamentallyflawfororganizeddata;byhavingmultipleentitiesand attributestogetherinone table makescategorizingandupdatingadatabase notonlydifficultbutin some casesimpossible. Anotherproblemsimilartothe above conflictinvolvesmore thanone albumcreatedbyan artist.Thisdatabase showsmultiple albumswiththe same artists.Fairlycommonforanartistto have more than one albumhoweverincreatinganorganizeddatabase thisisalsoafundamentallyflaw.If you wantedtosearch for a specificsongtitle butonlyrecall the artistswhocreatedthe song;ratherthan a narrow resultyoursearch parameters,youwouldbe presentedwithavastamountof songtitlesand albums.Bycreatingseparate tablessortingoutartistand songtitle findingaspecificsongorartist would make the resultmuchmore narrowand better. Andfinallythe genre columnisveryvastandwithtwothousandsongsonlya few genresare present.Thisisa massive problemthatcancreate terrible outcomesif notproperlyfixed.If youdecided one day youare sickof rock musicand decide todelete itfromyourdatabase.Half of yourdatabase is labeledgenre of rockmusic;youwill notonlyloose half yoursongsbutif throughthisdelete there were a fewsongsevenif labeledrockyouenjoyed;well now itiscompletelygone.Furthermore,lookingfor specificsongsorartistsbut usingthe genre wouldbe anightmare inthe results;consideringsomanyare of differentgenres.Bymakingaseparate columnandusingprimaryand foreignkeysIcan make this disasterintoa fixable anduseable searchoption;butalsoallow formore genrestobe addedwithease.
  • 2. 2) ThisdiagramI have createdshowswhat the new database will looklikeaswell asrelationships betweenthe columns. Bymakingseparate attribute columnswe canmake queuingandupdating very easy. The main reasonI chose thisdiagramissimplyupdating,adding,searching,fixingamongother actionsmakesthis veryeasy.Knowingeverysongcanhave differentgenres,albumsandartistsmake not onlya 1 to manyrelationshipsonthe othertablesbutalsoallowsforeignkeystobe placedinthe songtable fromall othertables.Bymakingprimarykeysthatare allowingeachcolumnnumberedin each table Iam allowingeachbitof informationlabeledwithaspecificIDof itsown.Havingthat makes all the informationinthisdatabase unique,easilyidentifiable andusefulforall the actionsmentioned above. Song song_id (primary key) song_title time_mins number_of_plays artist_id (foreign key) album_id (foreign key) Artist artist_id (primary_key) name Album album_id (primary key) album_title year genre
  • 3. 3) CREATE TABLE Song ( song_IdintNOT NULL Auto_increment,title varchar(50) NOTNULL, length_minstime(5), number_of_playsint(3),PRIMARYKEY(song_Id) ) AlterTable Song ADD columnartist_idintnotnull AlterTable song Addcolumnalbum_idintnotnull CREATE TABLE Artist ( artist_idintNOT null Auto_Increment,name varchar(100),PRIMARYKEY (artist_id) ) CREATE TABLE Album ( album_idintNOTnull Auto_increment,title varchar(100),yearint(4),genre varchar(4), PRIMARYKEY (album_id) ) 4) INSERT INTOSongVALUES ("heartbreak","3:20","10",NOTnull) INSERT INTOArtistVALUES("RockyMountaint",NOTnull) INSERT INTOAlbumVALUES("Heavenful", 2012, rock, NOT null) 5) INSERT INTOSong(title,time_mins,number_of_plays) SELECTsong,time,playsFROMmusic INSERT INTOArtist(name) SELECTdistinctartistFROMmusic INSERT INTOAlbum(title,year,genre) SELECTdistinctalbum, year,genre FROMmusic Update Song SetSong.album_id=(Selectdistinctalbum_idfromAlbum, musicwhereAlbum.album_id= music.albumandSong.title =music.song) Update Song SetSong.artist_id=(Selectdistinctartiis_idfromArtist,musicwhere Artist.name = music.artistandSong.song_id=music.song)