APM Welcome, APM North West Network Conference, Synergies Across Sectors
Music management system
1. A Database Project By -
CHERRY KEDIACHERRY KEDIA
NILESH PADWALNILESH PADWAL
2. INDEX
• Introduction
• Applications supported
• Overview Of Project
• Application Screenshot
• Data Management
• Technical Glossary
• Tables In ER- Diagram
• ER- Diagram
• Application Logic And Reports
• Future Scope
• Lessons Learned…
3. • What is it about?
The Music Database project is to categorize and catalog
every single piece of music for music info and reviews,
Rate and review albums, internet music service, listing
record collections, music downloading and sharing, etc.
• Why we chose it?
The idea of music database arose out of common
interest of project members in Music (Sangeet). The
concept seemed different and very interesting right in
the first go.
4. Applications Supported…
• Online music listening
• On demand music for streaming media
• Music guide
• Music quizzes
• Karaoke (sing-along) players
• Film and music studios i.e. music retailers
• Music library
•Music stores and internet radio
5. Overview of Project
• Concentration on online music streaming
• Songs added by admin, accessed by registered users.
• Search a song as per its album, genre, lyrics, artist
• Can create playlists
• Can download and share songs
• Select and maintain favorite songs
• Users can contribute by uploading the lyrics
• Users can maintain their music files on their account
8. Other Schema
Labels Data
Genre Data
Files and Images Data
Human Resources Schema
Users Data
Admin Data
Artist Data
Music Schema
Playlist Data
Lyrics Data
Albums
Songs Data
Data Management
9. Technical Glossary
TOOLS & IDE USED :
1.pgAdmin III
2. SQL DEVELOPER
3. NOTEPAD++
4.MySQLWorkbench
DATABASE USED :
1.ORACLE 11g (PL/SQL)
2.MICROSOFT EXCEL 2010
10. Tables In ER- Diagram
The Most Important Tables in our project:
•Songs (Title, Length, Album, Genre, Download
Permit, Share Link)
•Albums (Name, Release Date, Length, Total
Tracks, Genre, Label,
Image)
•Playlists (User Id, Name, Favorite Flag)
•Artist (Name, Total Songs, Total Albums, Image)
11. Few Other tables are:
• Users (Name Details, Authentication, Last Login,
Active Status)
• FrequencyHeard (User, Song, Album, Count, Week
No)
• SungBy (Song, Artist, Album)
• Includes (Playlist, Song, Album)
• Images (Name, Location Address)
• Genre (Name)
• Usertype (User position)
• UserFiles (Name, User, File size)
Table Description (contd..)
14. • Most common song searches according to various
factors.
• Most Selling Label i.e. label producing max music
albums which make it to users' playlists or favorite
list.
• Recommend albums to the user based on his favorite
genre
• Check if a new file can be uploaded based on the
storage space allotted to him as per the user type
and if it can then insert the file in his storage space
• Find the artist with max songs for a user/ Find an
artist the user is the biggest fan of as per his favorite
playlist
Application Logic And Reports
15. Reports Example
Recommend albums to the user based on his favorite genre
OUTPUT
Create or Replace Procedure Fav_Album
(P_ID IN NUMBER G_name OUT VARCHAR2) AS
V_Album_ID Number;
V_Playlist_ID Number;
Out_Album_Name Varchar2(20);
Begin
Select playList_Id INTO V_Playlist_ID from PlayList
Where user_Id = P_ID AND FavFlag=TRUE;
Select Count(Album_Id ) , Album_ID INTO V_Album_ID
From Includes
Where PlayList_Id = V_Playlist_Id AND ROWNUM=1
Group by Album_id
Order by Count( Album_id) DESC
Select Genre_Id INTO V_GId from Albums
Where Album_Id = V_Album_ID
Select AlbumName INTO Out_Album_Name from Albums
where Genre_Id = V_GId
AND Album_Id NOT IN (Select Distinct(Album_Id)
From Includes Where Playlist_Id = V_Playlist_Id
Order by ReleasedDtDesc;
G_name := Out_Album_Name ;
END Fav_Album;
16. Application Logic And Reports
create view New_Release as
select * from
(select * from Albums
Order by ReleasedDtdesc) as
desc
Where rownum< = 25;
Create a VIEW that lists 25 newly released albums
17. Reports Example
Create Or Replace Procedure FILE_INSERT ( ID IN NUMBER ,
V_Filename In VARCHAR2 , FILE_SZ IN NUMBER) Return Integer
IS
Count_SizeNumber(20);
BEGIN
Select Sum(FileSize) INTO Count_Size From UserFiles
Where User_Id = ID;
IF UserType_Id = 'Admin' Then
If Count_Size< 1000 AND (1000 - Count_size) >= FILE_SZ
Then
Insert Into UserFiles (Filename, User_id, FileSize)
Values (V_Filename, ID, FILE_SZ);
End If;
Else
If count_Size< 250 AND (250 - Count_size) >= FILE_SZ
Then
Insert Into UserFiles (Filename, User_id, FileSize)
Values (V_Filename, ID , FILE_SZ);
End If;
End If;
End FILE_INSERT ;
Check if a new file can be uploaded based on the storage space
allotted to him as per the user type and if it can then insert the file
in his storage space
OUTPUT
18. Reports Example
Create Or Replace Procedure Artist_Max_song (ID IN
NUMBER)IS
A_NameVARCHAR2(50);
Begin
Select Name INTO A_Name From Artists
Where Artist_id in
(Select Artist_id from Artists
Where Artist_id in
( SelectArtist_id From SungBy
Where Song_id in
( SelectSong_id From Includes
Where PlayList_id =
(Select PlayList_id From PlayList
Where User Id = ID AND FavFlag= TRUE)))
Group ByArtist_id
Order By Count(Artist_id))
Where RowNum<=1
END Artist_Max_song;
Find the artist with max songs for a user/ Find an artist the user is
the biggest fan for every particular user as per his favorite playlist
OUTPUT
19. Application Logic And Reports
select name artistName from (select *
from
(select a.name, sum(sf.songFreq)
artistFreq from
(selectf.Song_id, sum(f.count) songFreq
from FrequencyHeard f where
weekno =
to_number(to_char(sysdate,'WWYYYY'))
group by f.Song_id) sf
joinsungBysb on sb.song_id = sf.song_id
join artists a on a.artist_id =
sb.artist_id
group by a.name) af
order by af.artistFreqdesc)
whererownum = 1;
Billboard’s (likewise) Most Heard Artist of the week
OUTPUT
20. Application Logic And Reports
CREATE OR REPLACE FUNCTION
DEACTIVATE_USERS RETURN INTEGER AS
BEGIN
UPDATE USERS U
SET U.ACTIVESTATUS = 'N'
WHERE SYSDATE - U.LASTLOGINDT >
365 * 5; -- Deactivate users who have
not logged in for 5 years.
EXCEPTION WHEN OTHERS THEN
null; -- Do Nothing
END;
RETURN NULL;
END DEACTIVATE_USERS;
Function to deactivate a user id if he has not used the website
for a long time
21. Application Logic And Reports
CREATE OR REPLACE PROCEDURE
UPDATE_LAST_LOGIN (USER_ID NUMBER)
AS
v_userId USERS.USERS_ID%TYPE;
BEGIN
v_userId := USER_ID;
UPDATE USERS U
SET U.LASTLOGINDT = sysdate
WHERE U.USERS_ID = v_userId
AND U.ACTIVESTATUS = 'Y';
EXCEPTION WHEN OTHERS THEN
null ;
END;
END UPDATE_LAST_LOGIN ;
Update the last account status after every login by a user
22. Application Logic And Reports
CREATE OR REPLACE FUNCTION AUTHENTICATE
(VAR_EMAIL VARCHAR2, VAR_PASSWORD VARCHAR2)
RETURN NUMBER AS
v_user_pwd USERS.PASSWORD%TYPE;
result number;
BEGIN
SELECT U.PASSWORD INTO v_user_pwd
FROM USERS U
WHERE U.EMAIL = VAR_EMAIL
AND U.ACTIVESTATUS = 'Y';
IF v_user_pwd= VAR_PASSWORD THEN
result := 1;
ELSE
result := 0;
END IF;
EXCEPTION WHEN OTHERS THEN
-- If the email Id is invalid then the select
query will throw no data found exception
result := 0;
END;
END AUTHENTICATE;
Function to authenticate user details while log in
23. Future Scope
• Search a song by melody (entering notes, whistling,
tapping rhythm)
• Making music buddies on the basis of similar music
interests
• Commenting the playlists, rating and reviewing the
albums
• Creating chat rooms to discuss about upcoming or
newly released albums/records
• Providing licensed music streaming and downloads
by admin
24. Lessons Learned
• Application of the knowledge of database design.
• Intelligent database design to serve the purpose of the
applications that depend on it.
• Generation of data – Arrays used to create random data
for
• Applying knowledge of writing SQL queries and functions
– using joins to combine data from multiple tables
• Functions – Generic reports that take input parameters
to produce corresponding results