You are on page 1of 47

MIS 331

MusicMash Final Report


December 10, 2015

Kyndall Jonhston | kyndalljohnston@email.arizona.edu


Tyler Bauer | tylerbauer@email.arizona.edu
Joseph Khoury | josephkhoury@email.arizona.edu
Douglas Izzo | douglasizzo@arizona.edu

Table of Contents
Introduction ...............................................................................................................3
Questions When Building the Database ............................................................... 4
Assumptions.............................................................................................................. 4
ER Diagram: Preliminary ..........................................................................................5
ER Diagram: Implementation ................................................................................. 6
Normalized Relations ...............................................................................................7
Referential Integrity Constraints .......................................................................... 10
Indexes ....................................................................................................................... 11
Denormalization Decisions ..................................................................................... 11
SQL Code Used to Build Database ....................................................................... 12
Defining the Database: SQL Statements ..................................................................... 12
Populating the Database with Sample Data: Insert Statements .............................. 16

Implemented Database Structure........................................................................ 35


Properties of Fields of Tables in Implemented Database ............................... 36
Queries ..................................................................................................................... 39
User Documentation of Database ........................................................................ 43
Training and Use of Database .............................................................................. 45
Technology Issues .................................................................................................. 46
Lessons Learned ..................................................................................................... 47

Introduction

In order to provide our client MusicMash with a proper database system we incorporated multiple stages
within our design. Below is the operational view of our database by which the MusicMash employee will
view upon login. This paper will then outline the steps in order to come the proposed scenario as well as
provide insight on lessons learned throughout the project.

Questions When Building the Database

In starting out, we proposed a series of questions to MusicMash as it pertained


to building the database.
1. Do people have the ability to purchase songs after their prescription
runs out?
a. No
2. Is data about a customer that has an expired membership kept after the
membership expired?
a. Yes
3. Is the company going to update its management system after 10 years?
a. Yes
4. d. How many songs will be in the database at one time?
a. 100,000,000
5. e. Is customer name necessary to Music Mash besides credit card
information?
a. Yes

Assumptions

Next, we created an ER Diagram to serve as the foundation in building the


database. Assumptions were made in building the database for MusicMash.
Please reference the assumptions to follow for our ER Diagrams and
Relational Model. Assumptions are denoted by a (*) in the ER diagrams.
*1 Assume CUSTOMER rates at least one SONG
*2 Assume SONG is rated by at least one CUSTOMER
*3 Assume CUSTOMER does not have to purchase ALBUM
*4 Assume ALBUM does not have to be purchased by CUSTOMER
*5 Assume SONG has one and only one ARTIST
*6 Assume ARTIST has at least one SONG
*7 Assume SONG has one and only one RECORD LABEL
*8 Assume RECORD LABEL has at least one SONG
*9 Assume RECORD LABEL has one and only one ACCOUNT EXEC
*10 Assume ACCOUNT EXEC has at least one RECORD LABEL
*11 Assume ALBUM has one and only one ARTIST
*12 Assume ARTIST has at least one ALBUM
*13 Assume SONG has one and only one ALBUM
*14 Assume CUSTOMER does not have to purchase SONG
*15 Assume SONG does not have to be purchased by CUSTOMER
*16 Assume CUSTOMER creates at least one STATION
*17 Assume STATION is created by at least one CUSTOMER
*18 Assume SONG belongs to at least one STATION
*19 Assume STATION has at least one SONG
*20 Assume ARTIST signs one and only one RECORD LABEL
*21 Assume RECORD LABEL is signed by at least one ARTIST

ER Diagram: Preliminary

ER Diagram: Implementation

Normalized Relations

We needed to prepare our ER Diagram to be translated in to SQL code, which


would then be implemented in our database management system. We defined
each constraint and how it would be related to the relational attributes
provide by the business scenario.

Referential Integrity Constraints

Before we inserted data in to our database, we needed to define the


constraints to eliminate data redundancy, as well as form the primary keys.
The foreign keys help ensure alignment of the tables.
A. Account Exec must have its own primary key of EID in order to keep
track of each specific Executive.
B. Each Artist must have its own ArtID in order to keep track of each
individual Artist.
C. The customer table must have a primary key denoting each indivdule
customer of CID.
D. Each time a customer is contacted must be recorded with its own id of
ConID. Customer data is recorded in the contact table meaning that the
data must reference the customer table for each specific customer id
CID.
E. Each individual song must have its own identification which requires a
primary key of SongID. Since an Artist is associated with each song, a
foreign key of ArtID is necessary. Another foreign key of RID will be
needed to denote the specific record label assigned to the song.
F. The customer and song interaction must be recorded for each specific
interaction between therefore needing a primary key of CustSong_ID.
Since the customer is recorded in this interaction the foreign key CID
must be taken from Customer for reference purposes. Also the song
that is interacted with the customer must be recorded, therefore the
use of SongID must be taken from Song.
G. The interaction of a customer purchasing a song must be recorded with
the primary key of CSP_ID. Since the customer is recorded in this
interaction the foreign key CID must be taken from Customer for
reference purposes. Also the song that is interacted with the customer
must be recorded, therefore the use of SongID must be taken from
Song.
H. Albums must be recorded with the primary key of AlbID for each album
and since artists go hand and hand with albums, the artist id of ArtID
must be referenced from table Artist.
I. Customers can create stations which must be recorded by a primary
key of CustStat_ID for every single station created. Since customer data
is recorded a foreign key of CID must reference the customer table and
the Album id must reference the Album table of ALBID.
J. The table that records data for non subscribers contains information
regarding customers which means it must be cross referenced with the
table for customers CID.
K. The Record Label table must have its own id denoting the recordlabel
as a primary key called RID. This table will reference the account

10

L.
M.

N.
O.
P.

executives therefore it must have a foreign key of EID to denote the


account executives by their id.
Each station created for songs must have its own StationId denoting
the specific station.
The station song table captures which songs are in each station and
have their own distinct code called Station_SongID. They will reference
both the station and the song with the denotations of StationID and
SongID respectively.
The subscription table denotes what type of subscription is selected by
the primary key of SuselectID.
The subscriber table must pull together information from the customer
tables CID to denote the customer and must also the subscription type
from the table subscription as SubselectID.
Each customers interaction with an album must be recorded by the
primary key of Cust_ALb. This table must draw from the AlbID as well
as the CID from the Album and Customer table respectively.

Indexes

We need a four-pronged index for songrating, songtype, songratingtime, and


songskiptimes. We need this index so we can calculate the main algorithm
MusicMash is looking for us to solve. Our main problem is that we need to find
whether customers like certain songs in the day or at night and certain types
of song. This composite index meets that requirement. The usage frequency
index was created because the case asked us how often songs are played.
The loyalty of subscribers index is necessary because MusicMash wants to
identify loyal customers to give them discounts.

Denormalization Decisions

We have decided not to denomalize any tables because all of our tables
contain useful data. We have made the minimum amount of tables required to
solve this case under our desire and we want to keep the data as crisp and
clean for the user as possible. One potential denormalization is the subscriber
and non-subscriber tables but we decided against it because subscriber has a
relationship with subscription. If we denormalized subscriber and nonsubscriber, we would have a lot of unnecessary null values. We believe we
provide a strong database that does not need to be denormalized. It is
efficient in search with the indexes and because we used so few indexes
there's no need to denormalize the tables for searchability purposes. Our
strong index design that aligns with customer needs also allows us to keep
the tables the way they are and if we denormalized those tables we may need
to get rid of some of those indexes. The current design is the most user
friendly possible because if we were MusicMash we would want these indexes
for search and because the database has common sense to it.

11

SQL Code Used to Build Database

Defining the Database: SQL Statements


The CREATE TABLE and INSERT statements were needed to create the tables
in our database. The INSERT statements are sample data that we introduced
to our database by way of SQL code.
ACCOUNTEXC TABLE
CREATE TABLE ACCOUNTEXEC
(
EId VARCHAR2(3) Not NULL,
EName VARCHAR2(20),
CONSTRAINT ACCOUNTEXEC_PK PRIMARY KEY (EId)
);
ALBUM TABLE
CREATE TABLE ALBUM
(
AlbID VARCHAR2(7) NOT NULL,
ArtID VARCHAR2(10) NOT NULL,
AlbCost NUMBER(5,2),
Albname VARCHAR2(25),
Genre VARCHAR2(10),
CONSTRAINT ALBUM_PK PRIMARY KEY (AlbID),
CONSTRAINT ALBUM_FK FOREIGN KEY (ArtID) REFERENCES ARTIST
);
ARTIST TABLE
CREATE TABLE ARTIST
(
ArtID VARCHAR2(10),
ArtName VARCHAR2(30),
CONSTRAINT ARTIST_PK PRIMARY KEY (ArtID)
);
CONTACT TABLE
CREATE TABLE CONTACT
(
CId VARCHAR2(10) NOT NULL,
ConID VARCHAR2(10) NOT NULL,
Ctype VARCHAR2(20),
Notification VARCHAR2(20),
CONSTRAINT CONTACT_PK PRIMARY KEY (ConID),
CONSTRAINT CONTACT_FK FOREIGN KEY (CId) REFERENCES CUSTOMER(CId)
);
CUSTOMER TABLE
CREATE TABLE CUSTOMER
(

12

CId VARCHAR2(10) NOT NULL,


CType VARCHAR2(2) NOT NULL,
CStreet VARCHAR2(58),
CState VARCHAR2(14),
CZip VARCHAR2(10),
CCity VARCHAR2(44),
CSignupDate DATE,
CSignupTime TIMESTAMP,
CDob DATE,
CEmail VARCHAR2(100),
CNAME VARCHAR2(30),
CGENDER VARCHAR2(2),
CONSTRAINT CUSTOMER_PK PRIMARY KEY (CID)
);
CUSTOMER_ALBUM TABLE
CREATE TABLE CUSTOMER_ALBUM
(
CUST_ALB VARCHAR2(7),
CID VARCHAR2(10),
ALBID VARCHAR2(7),
PURCHASEALBUMTIME DATE,
CONSTRAINT CUSTOMER_ALBUM_PK PRIMARY KEY (CUST_ALB),
CONSTRAINT CUSTOMER_ALBUM_FK1 FOREIGN KEY (CId) REFERENCES CUSTOMER,
CONSTRAINT CUSTOMER_ALBUM_FK2 FOREIGN KEY (ALBID) REFERENCES ALBUM
);
CUSTOMER_SONG TABLE
CREATE TABLE CUSTOMER_SONG
(
CustSong_ID VARCHAR2(7) NOT NULL,
CId VARCHAR2(10) NOT NULL,
SongId VARCHAR2(7) NOT NULL,
SongRating VARCHAR2(2),
SongRatingTime TIMESTAMP NOT NULL,
SongType VARCHAR2(8),
SongSkipTimes INTEGER,
SongUsageFrequency NUMBER(3),
ListeningTime TIMESTAMP,
SkipTimeDate TIMESTAMP,
CONSTRAINT CUSTOMER_SONG_PK PRIMARY KEY (CustSong_ID),
CONSTRAINT CUSTOMER_SONG_FK1 FOREIGN KEY (CId) REFERENCES CUSTOMER,
CONSTRAINT CUSTOMER_SONG_FK2 FOREIGN KEY (SongId) REFERENCES SONG
);
CUSTOMER_SONGP TABLE
CREATE TABLE CUSTOMER_SONGP
(
CSP_ID VARCHAR2(17) NOT NULL,
CId VARCHAR2(10) NOT NULL,
SongId VARCHAR2(7) NOT NULL,

13

Song_Price NUMBER (5,2),


PurchaseTime TIMESTAMP,
CONSTRAINT CUSTOMER_SONGP_PK PRIMARY KEY (CSP_ID),
CONSTRAINT CUSTOMER_SONGP_FK1 FOREIGN KEY (CId) REFERENCES CUSTOMER,
CONSTRAINT CUSTOMER_SONGP_FK2 FOREIGN KEY (SongId) REFERENCES SONG
);
CUSTOMER_STATION TABLE
CREATE TABLE CUSTOMER_STATION
(
CustStat_ID VARCHAR2(5) NOT NULL,
CId VARCHAR2(10) NOT NULL,
ALBID VARCHAR2(7) NOT NULL,
CreationSDate DATE,
CONSTRAINT STATION_PK1 PRIMARY KEY (CustStat_ID),
CONSTRAINT CUSTOMER_STATION_FK10 FOREIGN KEY (Cid) REFERENCES
CUSTOMER,
CONSTRAINT CUSTOMER_STATION_FK20 FOREIGN KEY (ALBID) REFERENCES ALBUM
);
NON_SUBSCRIBER TABLE
CREATE TABLE NON_SUBSCRIBER
(
CID VARCHAR2(10) NOT NULL,
NSDuration VARCHAR2(5),
NSStartTime TIMESTAMP,
NSendTime TIMESTAMP,
CONSTRAINT NON_SUBSCRIBER_FK FOREIGN KEY (CId) REFERENCES CUSTOMER
);
RECORDLABEL TABLE
CREATE TABLE RECORDLABEL
(
RId VARCHAR2(3) NOT NULL,
EId VARCHAR2(3) NOT NULL,
RecName VARCHAR2(20),
ProfitRatio NUMBER(5,1),
CONSTRAINT RECORDLABEL_PK PRIMARY KEY (Rid),
CONSTRAINT RECORDLABEL_FK FOREIGN KEY (EId) REFERENCES
ACCOUNTEXEC(EId)
);
SONG TABLE
CREATE TABLE SONG
(
SongID VARCHAR2(7) NOT NULL,
ArtID VARCHAR2(10) NOT NULL,
RId VARCHAR2(3) NOT NULL,
SName VARCHAR2(20),
SGenre VARCHAR2(20),
SArtist VARCHAR2(20),

14

SReleaseDate DATE,
CONSTRAINT SONG_PK PRIMARY KEY (SongID),
CONSTRAINT SONG_FK1 FOREIGN KEY (ArtID) REFERENCES ARTIST,
CONSTRAINT SONG_FK2 FOREIGN KEY (RId) REFERENCES RECORDLABEL
);
STATION TABLE
CREATE TABLE STATION
(
StationID varchar2(5) NOT NULL,
StartType varchar2(5),
CONSTRAINT STATION_PK PRIMARY KEY (StationID)
);
STATION_SONG TABLE
CREATE TABLE STATION_SONG
(
STATSONGID VARCHAR2(10) NOT NULL,
StationID VARCHAR2(5) NOT NULL,
SongId VARCHAR2(7) NOT NULL,
CONSTRAINT STATION_SONG_PK PRIMARY KEY (STATSONGID),
CONSTRAINT STATION_SONG_FK1 FOREIGN KEY (StationId) REFERENCES
STATION,
CONSTRAINT STATION_SONG_FK2 FOREIGN KEY (SongId) REFERENCES SONG
);
SUBSCRIBER TABLE
CREATE TABLE SUBSCRIBER
(
CId VARCHAR2(10) NOT NULL,
SubselectID VARCHAR (6) NOT NULL,
CCNumber NUMBER(16),
CCExpMonth NUMBER(2),
CCExpYear NUMBER(4),
CCSecurityCode NUMBER(3),
CCPaypalOption VARCHAR2(1),
SDuration VARCHAR2(30),
SendDate DATE,
CONSTRAINT SUBSCRIBER_FK FOREIGN KEY (CId) REFERENCES CUSTOMER(CId),
CONSTRAINT SUBSCRIBER_FK2 FOREIGN KEY (SubselectId) REFERENCES
SUBSCRIPTION(SubselectId)
);
SUBSCRIPTION TABLE
CREATE TABLE SUBSCRIPTION
(
SubselectId VARCHAR2(6) NOT NULL,
SubscriptionType VARCHAR2(2),
CONSTRAINT SUBSCRIPTION_PK PRIMARY KEY (SubselectId)
);

15

Indexes
CREATE INDEX idx_MainAlg ON CUSTOMER_SONG(Songrating, Songtype,
Songratingtime, Songskiptimes);
CREATE INDEX idx_UsageFreq ON CUSTOMER_SONG(Songusagefrequency);
CREATE INDEX idx_CustomerLoyalty ON SUBSCRIBER(SDuration);

Populating the Database with Sample Data: Insert Statements


ACCOUNTEXC TABLE
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT

INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO

ACCOUNTEXEC
ACCOUNTEXEC
ACCOUNTEXEC
ACCOUNTEXEC
ACCOUNTEXEC
ACCOUNTEXEC
ACCOUNTEXEC
ACCOUNTEXEC
ACCOUNTEXEC
ACCOUNTEXEC

VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES

('001','Pulson Records');
('002', 'Fly Records');
('003','Yo Records');
('004','Rap Records');
('005','Crash Records');
('006','Latin Records');
('007','Titan Records');
('008','Retoggle Records');
('009','Gofish Records');
('010','Bingo Records');

ALBUM TABLE
INSERT INTO ALBUM VALUES
('0000001','0000000001',20.99,'TheComeback','Rock'
);
INSERT INTO ALBUM VALUES
('0000002','0000000002',20.99,'TheReturn','Hip-Hop'
);
INSERT INTO ALBUM VALUES
('0000003','0000000003',2.99,'Love','Latin'
);
INSERT INTO ALBUM VALUES
('0000004','0000000004',0.99,'Loving','Latin'
);
INSERT INTO ALBUM VALUES
('0000005','0000000005',30.99,'Adventure','Latin'
);
INSERT INTO ALBUM VALUES
('0000006','0000000006',10.99,'Journey','Latin'
);
INSERT INTO ALBUM VALUES
('0000007','0000000007',40.99,'Baby','Pop'
);
INSERT INTO ALBUM VALUES
('0000008','0000000008',10.99,'Star','Pop'
);
INSERT INTO ALBUM VALUES
('0000009','0000000009',30.99,'Yoyo','Rap'

16

);
INSERT INTO ALBUM VALUES
('0000010','0000000010',20.99,'Comingback','Rap'
);
ARTIST
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT

TABLE
INTO ARTIST
INTO ARTIST
INTO ARTIST
INTO ARTIST
INTO ARTIST
INTO ARTIST
INTO ARTIST
INTO ARTIST
INTO ARTIST
INTO ARTIST

VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES

('0000000001','PlusBoys');
('0000000002','Jerseyboys');
('0000000003','Princeroyce');
('0000000004','Nickyjam');
('0000000005','EnriqueInglesias');
('0000000006','Shakira');
('0000000007','JustinBieber');
('0000000008','SelenaGomez');
('0000000009','LittleJ');
('0000000010','Mr.P');

CONTACT TABLE
INSERT INTO CONTACT VALUES
('0000000001','0000000001','Email','1
INSERT INTO CONTACT VALUES
('0000000003','0000000002','Email','1
INSERT INTO CONTACT VALUES
('0000000005','0000000003','Email','1
INSERT INTO CONTACT VALUES
('0000000007','0000000004','Email','1
INSERT INTO CONTACT VALUES
('0000000009','0000000005','Email','1
INSERT INTO CONTACT VALUES
('0000000011','0000000006','Email','1
INSERT INTO CONTACT VALUES
('0000000013','0000000007','Email','1
INSERT INTO CONTACT VALUES
('0000000015','0000000008','Email','1
INSERT INTO CONTACT VALUES
('0000000017','0000000009','Email','1
INSERT INTO CONTACT VALUES
('0000000019','0000000010','Email','1

Week Reminder');
Week Reminder');
Week Reminder');
Week Reminder');
Week Reminder');
Week Reminder');
Week Reminder');
Week Reminder');
Week Reminder');
Week Reminder');

CUSTOMER TABLE
INSERT INTO CUSTOMER VALUES
(
'0000000001',
'NS',
'Park',
'Arizona',
'85719',
'Tucson',
'24-Nov-2015',
'24-Nov-2015 11:19:00AM',
'22-Jun-1995',

17

'FrankSinatra@gmail.com',
Frank Sinatra,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000002',
'NS',
'Broadway',
'Arizona',
'85028',
'Phoenix',
'24-Nov-2015',
'24-Nov-2015 11:19:00AM',
'22-May-1975',
'peterthiel@paypal.com',
Peter Thiel,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000003',
'NS',
'Rightfella',
'Alaska,
'30019',
'Anchorage',
'14-Jan-2015',
'14-Jan-2015 01:19:00AM',
'02-Jun-1993',
'kingkong@gmail.com',
King Kong,
F
);
INSERT INTO CUSTOMER VALUES
(
'0000000004',
'S',
'Mant',
'Florida,
'65028',
'Daytona',
'26-Nov-2015',
'26-Nov-2015 06:15:00AM',
'10-Apr-1974',
'gregl@paypal.com',
Greg Lapiner,
F
);
INSERT INTO CUSTOMER VALUES
(
'0000000005',

18

'NS',
'Trench',
'New Mexico,
'17019',
'New Mexico',
'20-Jan-2015',
'20-Jan-2015 01:19:00AM',
'15-Aug-1990',
'JustinBeebs@gmail.com',
Justin Beebs,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000006',
'S',
'Broadway',
'New York,
'10001',
'New York',
'03-Dec-2015',
'03-Dec-2015 07:19:00PM',
'03-Dec-1979',
'seanparker@napster.com',
Sean Parker,
F
);
INSERT INTO CUSTOMER VALUES
(
'0000000007',
'NS',
'Alder',
'New York',
'10701',
'Yonkers',
'07-Aug-2015',
'07-Aug-2015 03:59:00PM',
'10-July-1993',
'DerickJeter@gmail.com',
Derick Jeter,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000008',
'S',
'University Ave',
'New York',
'10003',
'New York',

19

'03-Nov-2015',
'03-Nov-2015 05:19:00PM',
'19-Mar-1982',
'Johnny@facebook.com',
Johnny Football,
F
);
INSERT INTO CUSTOMER VALUES
(
'000000009',
'NS',
'Gitwell',
'Maine,
'10621',
'Albany',
'17-Mar-2015',
'17-Mar-2015 03:59:00PM',
'10-Feb-1925',
'AbrahamLink@gmail.com',
Abraham Linkoln,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000010',
'S',
'University Ave',
'New York,
'10003',
'New York',
'03-Nov-2015',
'03-Nov-2015 05:19:00PM',
'18-Mar-1982',
'eduardosaverin@facebook.com',
Eduardo Saver,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000011',
'NS',
'Park',
'Arizona',
'85719',
'Tucson',
'07-Dec-2015',
'07-Dec-2015 09:19:00AM',
'22-May-1995',
'mattp@gmail.com',
Matt Presto,
F
);

20

INSERT INTO CUSTOMER VALUES


(
'0000000012',
'S',
'Park',
'Arizona',
'85719',
'Tucson',
'07-Nov-2015',
'07-Nov-2015 09:19:00AM',
'23-May-1995',
'johndoejr@email.arizona.edu',
John Doe,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000013',
'NS',
'Park',
'Arizona',
'85719',
'Tucson',
'07-Nov-2015',
'07-Nov-2015 09:19:00AM',
'22-May-1995',
'lucasde@gmail.com',
Lucas De,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000014',
'S',
'Park',
'Arizona',
'85719',
'Tucson',
'15-Nov-2015',
'15-Nov-2015 09:19:00AM',
20,
'25-May-1995',
'cynthiarae@email.arizona.edu',
Cynthia Rae,
M
);
INSERT INTO CUSTOMER VALUES
(
'0000000015',
'NS',
'Park',
'Arizona',

21

'85719',
'Tucson',
'07-Oct-2015',
'07-Oct-2015 09:19:00AM',
20,
'22-May-1997',
'john@email.arizona.edu',
John Lam,
F
);
INSERT INTO CUSTOMER VALUES
(
'0000000016',
'S',
'Park',
'Arizona',
'85719',
'Tucson',
'09-Nov-2015',
'09-Nov-2015 09:19:00AM',
20,
'09-Sep-1995',
'johnrichardsmith@email.arizona.edu'
John Richard,
F
);
INSERT INTO CUSTOMER VALUES
(
'0000000017',
'NS',
'Park',
'Arizona',
'85719',
'Tucson',
'08-Oct-2015',
'08-Oct-2015 09:19:00AM',
'09-May-1997',
'kelsey@email.arizona.edu',
Kelsey Han,
F
);
INSERT INTO CUSTOMER VALUES
(
'0000000018',
'S',
'Park',
'Arizona',
'85719',
'Tucson',
'20-Nov-2015',
'20-Nov-2015 09:19:00AM',
'10-Sep-1995',

22

'ricardozavala@email.arizona.edu',
Ricardo Dozavala,
F
);
INSERT INTO CUSTOMER VALUES
(
'0000000019',
'NS',
'Park',
'Arizona',
'85715',
'Tucson',
'15-Oct-2015',
'15-Oct-2015 09:19:00AM',
'20-May-1997',
'brittney@email.arizona.edu',
Brittney Spears,
F
);
INSERT INTO CUSTOMER VALUES
(
'0000000020',
'S',
'Park',
'Arizona',
'85719',
'Tucson',
'20-Dec-2015',
'20-Dec-2015 09:19:00AM',
'10-Oct-1995',
'cristianoronaldo@email.arizona.edu',
Christiano Ronaldo,
F
);
CUSTOMER_SONG TABLE
INSERT INTO CUSTOMER_SONG VALUES
('0000001','0000000001','0000001','10','22-Nov-2015
04:59:00PM','Mellow',1,23,'23-Nov-2015 03:10:00PM','10-Jan-2015
06:53:00AM');
INSERT INTO CUSTOMER_SONG VALUES
('0000002','0000000002','0000002','9','18-Dec-2015
04:59:00PM','Mellow',2,57,'13-Dec-2015 10:52:00PM','11-Feb-2015
06:23:00PM');
INSERT INTO CUSTOMER_SONG VALUES
('0000003','0000000003','0000003','8','21-Jan-2015
04:59:00PM','Fast',3,683,'03-Jan-2015 05:32:00AM','12-May-2015
08:53:00AM');
INSERT INTO CUSTOMER_SONG VALUES
('0000004','0000000004','0000004','7','23-Aug-2015

23

04:59:00PM','Workout',4,1,'18-Aug-2015 08:02:00PM','13-Apr-2015
02:53:00AM');
INSERT INTO CUSTOMER_SONG VALUES
('0000005','0000000005','0000005','533','25-Jun-2015
04:59:00PM','Slowdown',5,23,'12-Jun-2015 12:02:00AM','14-Jan-2015
03:53:00PM');
INSERT INTO CUSTOMER_SONG VALUES
('0000006','0000000006','0000006','211','26-Feb-2015
04:59:00PM','Fast',6,23,'09-Feb-2015 05:02:00PM','15-Jan-2015
06:13:00AM');
INSERT INTO CUSTOMER_SONG VALUES
('0000007','0000000007','0000007','432','02-Jul-2015
04:59:00PM','Roadtrip',7,23,'11-Jul-2015 01:12:00AM','17-Jan-2015
02:53:00PM');
INSERT INTO CUSTOMER_SONG VALUES
('0000008','0000000008','0000008','18','03-Mar-2015
04:59:00PM','Relax',8,8,'28-Mar-2015 05:32:00PM','18-Mar-2015
01:53:00AM');
INSERT INTO CUSTOMER_SONG VALUES
('0000009','0000000009','0000009','8','04-May-2015
04:59:00PM','Sleepy',9,101,'26-May-2015 02:02:00AM','19-Feb-2015
02:27:00PM');
INSERT INTO CUSTOMER_SONG VALUES
('0000010','0000000010','0000010','5','05-Nov-2015
04:59:00PM','Mellow',10,23,'10-Nov-2015 02:02:00PM','20-Jan-2015
07:23:00AM');
CUSTOMER_SONGP TABLE
INTO CUSTOMER_SONGP VALUES
(
'00000000000000001',
'0000000001',
'0000001',
2.99,
'30-Jun-2015 10:30:00PM'
);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000002',
'0000000002',
'0000002',
1.99,
'01-NOV-2015 10:50:00PM'
);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000003',
'0000000003',
'0000003',
2.99,
'04-OCT-2015 09:30:00AM'

24

);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000004',
'0000000004',
'0000004',
1.99,
'14-JAN-2015 04:30:00PM'
);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000005',
'0000000005',
'0000005',
2.99,
'25-DEC-2015 02:00:00PM'
);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000006',
'0000000006',
'0000006',
1.99,
'08-AUG-2015 11:30:00AM'
);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000007',
'0000000007',
'0000007',
0.99,
'10-JUN-2015 01:30:00PM'
);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000008',
'0000000008',
'0000008',
0.99,
'01-MAY-2015 12:15:00PM'
);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000009',
'0000000009',
'0000009',
1.99,
'22-JUN-2015 08:15:00PM'
);
INSERT INTO CUSTOMER_SONGP VALUES
(
'00000000000000010',

25

'0000000010',
'0000010',
2.99,
'14-FEB-2015 07:30:00PM'
);
CUSTOMER_ALBUM TABLE
INSERT INTO CUSTOMER_ALBUM
(
'0000001',
'0000000001',
'0000001',
'05-May-2015'
);
INSERT INTO CUSTOMER_ALBUM
(
'0000002',
'0000000002',
'0000002',
'05-Dec-2016'
);
INSERT INTO CUSTOMER_ALBUM
(
'0000003',
'0000000003',
'0000003',
'05-May-2017'
);
INSERT INTO CUSTOMER_ALBUM
(
'0000004',
'0000000004',
'0000004',
'05-May-2018'
);
INSERT INTO CUSTOMER_ALBUM
(
'0000005',
'0000000005',
'0000005',
'05-May-2016'
);
INSERT INTO CUSTOMER_ALBUM
(
'0000006',
'0000000006',
'0000006',
'05-May-2017'
);
INSERT INTO CUSTOMER_ALBUM
(

VALUES

VALUES

VALUES

VALUES

VALUES

VALUES

VALUES

26

'0000007',
'0000000007',
'0000007',
'05-May-2016'
);
INSERT INTO CUSTOMER_ALBUM VALUES
(
'0000008',
'0000000008',
'0000008',
'05-May-2017'
);
INSERT INTO CUSTOMER_ALBUM VALUES
(
'0000009',
'0000000009',
'0000009',
'05-May-2018'
);
INSERT INTO CUSTOMER_ALBUM VALUES
(
'0000010',
'0000000010',
'0000010',
'05-May-2017'
);
CUSTOMER_STATION TABLE
INSERT INTO CUSTOMER_STATION
(
'00001',
'0000000001',
'0000001',
'24-Nov-2015'
);
INSERT INTO CUSTOMER_STATION
(
'00002',
'0000000002',
'0000002',
'14-Dec-2015'
);
INSERT INTO CUSTOMER_STATION
(
'00003',
'0000000003',
'0000003',
'10-Jan-2015'
);
INSERT INTO CUSTOMER_STATION
(
'00004',

VALUES

VALUES

VALUES

VALUES

27

'0000000004',
'0000004',
'11-Jun-2015'
);
INSERT INTO CUSTOMER_STATION
(
'00005',
'0000000005',
'0000005',
'02-Jul-2014'
);
INSERT INTO CUSTOMER_STATION
(
'00006',
'0000000006',
'0000006',
'19-Aug-2015'
);
INSERT INTO CUSTOMER_STATION
(
'00007',
'0000000007',
'0000007',
'30-May-2015'
);
INSERT INTO CUSTOMER_STATION
(
'00008',
'0000000008',
'0000008',
'23-Feb-2015'
);
INSERT INTO CUSTOMER_STATION
(
'00009',
'0000000009',
'0000009',
'13-Aug-2015'
);
INSERT INTO CUSTOMER_STATION
(
'00010',
'0000000010',
'0000010',
'18-Mar-2015'
);

VALUES

VALUES

VALUES

VALUES

VALUES

VALUES

NON_SUBSCRIBER TABLE
INSERT INTO NON_SUBSCRIBER VALUES
(
'0000000003',

28

'30Day',
'14-Jan-2015',
'14-Feb-2015'
);
INSERT INTO NON_SUBSCRIBER
(
'0000000005',
'30Day',
'20-Jan-2015',
'20-Feb-2015'
);
INSERT INTO NON_SUBSCRIBER
(
'0000000007',
'30Day',
'07-Aug-2015',
'07-Sep-2015'
);
INSERT INTO NON_SUBSCRIBER
(
'0000000009',
'30Day',
'17-Mar-2015',
'17-Apr-2015'
);
INSERT INTO NON_SUBSCRIBER
(
'0000000013',
'30Day',
'07-Nov-2015',
'07-Dec-2015'
);
INSERT INTO NON_SUBSCRIBER
(
'0000000011',
'30Day',
'07-Dec-2015',
'07-Jan-2015'
);
INSERT INTO NON_SUBSCRIBER
(
'0000000015',
'30Day',
'07-Oct-2015',
'07-Nov-2015'
);
INSERT INTO NON_SUBSCRIBER
(
'0000000017',
'30Day',
'08-Oct-2015',
'08-Nov-2015'

VALUES

VALUES

VALUES

VALUES

VALUES

VALUES

VALUES

29

);
INSERT INTO NON_SUBSCRIBER VALUES
(
'0000000019',
'30Day',
'15-Oct-2015',
'15-Nov-2015'
);
RECORDLABEL
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO

TABLE
RECORDLABEL
RECORDLABEL
RECORDLABEL
RECORDLABEL
RECORDLABEL
RECORDLABEL
RECORDLABEL
RECORDLABEL
RECORDLABEL
RECORDLABEL

VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES

('001','001','Roxxy',.07);
('002','002','City',.04);
('003','003','Dixie',.05);
('004','004','Shelton',.06);
('005','005','Dancxing',.07);
('006','006','Beijing',.08);
('007','007','Shanghai',.09);
('008','008','Barca',.01);
('009','009','Madrid',.03);
('010','010','LA',.04);

SONG TABLE
INSERT INTO SONG VALUES
('0000001','0000000001','001','Flying','Rock','Plus Boys','14-Oct1961');
INSERT INTO SONG VALUES
('0000002','0000000002','002','Camping','Latin','Jersey Boys','10-Feb1962');
INSERT INTO SONG VALUES
('0000003','0000000003','003','Hiking','Rock','Princeroyce','18-Jan1963');
INSERT INTO SONG VALUES
('0000004','0000000004','004','Sleeping','Rock','Nickyjam','05-Mar1964');
INSERT INTO SONG VALUES
('0000005','0000000005','005','Crying','Rock','EnriqueInglesias','12Apr-1965');
INSERT INTO SONG VALUES
('0000006','0000000006','006','Jumping','Rock','Shakira','22-May1966');
INSERT INTO SONG VALUES
('0000007','0000000007','007','Falling','Rock','JustinBieber','25-Jun1967');
INSERT INTO SONG VALUES
('0000008','0000000008','008','Laughing','Rock','SelenaGomez','30-Jul1968');
INSERT INTO SONG VALUES
('0000009','0000000009','009','Coding','Rock','LittleJ','11-Aug1969');
INSERT INTO SONG VALUES
('0000010','0000000010','010','Sitting','Rock','Mr.P','09-Sep-2015');

30

STATION TABLE
INSERT INTO STATION
INSERT INTO STATION
INSERT INTO STATION
INSERT INTO STATION
INSERT INTO STATION
INSERT INTO STATION
INSERT INTO STATION
INSERT INTO STATION
INSERT INTO STATION
INSERT INTO STATION

VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES

('00001','00001');
('00002','00002');
('00003','00003');
('00004','00004');
('00005','00005');
('00006','00006');
('00007','00007');
('00008','00008');
('00009','00009');
('00010','00010');

STATION_SONG TABLE
INSERT INTO STATION_SONG VALUES
('0000000001','00001','0000001'
);
INSERT INTO STATION_SONG VALUES
('0000000002','00002','0000002'
);
INSERT INTO STATION_SONG VALUES
('0000000003','00003','0000003'
);
INSERT INTO STATION_SONG VALUES
('0000000004','00004','0000004'
);
INSERT INTO STATION_SONG VALUES
('0000000005','00005','0000005'
);
INSERT INTO STATION_SONG VALUES
('0000000006','00006','0000006'
);
INSERT INTO STATION_SONG VALUES
('0000000007','00007','0000007'
);
INSERT INTO STATION_SONG VALUES
('0000000008','00008','0000008'
);
INSERT INTO STATION_SONG VALUES
('0000000009','00009','0000009'
);
INSERT INTO STATION_SONG VALUES
('0000000010','00010','0000010'
);
SUBSCRIBER TABLE
INSERT INTO SUBSCRIBER VALUES
(
'0000000002',
'000001',
1234123412341234,

31

12,2016,123,
'N',
'1MONTH',
'24-Dec-2015'
);
INSERT INTO SUBSCRIBER
(
'0000000004',
'000002',
8843147296055194,
09,2017,492,
'N',
'1MONTH',
'18-Dec-2015'
);
INSERT INTO SUBSCRIBER
(
'0000000006',
'000003',
0752117991236829,
09,2017,422,
'N',
'1MONTH',
'03-Jan-2015'
);
INSERT INTO SUBSCRIBER
(
'0000000008',
'000004',
0752132991236829,
03,2015,422,
'N',
'TRIAL',
'20-Dec-2015'
);
INSERT INTO SUBSCRIBER
(
'0000000010',
'000005',
0752117211236829,
09,2015,422,
'N',
'1MONTH',
'03-Dec-2015'
);
INSERT INTO SUBSCRIBER
(
'0000000012',
'000006',
0752117992336829,
05,2017,422,
'N',

VALUES

VALUES

VALUES

VALUES

VALUES

32

'1MONTH',
'07-Dec-2015'
);
INSERT INTO SUBSCRIBER
(
'0000000014',
'000007',
0752123991236829,
09,2015,414,
'N',
'1MONTH',
'15-Dec-2015'
);
INSERT INTO SUBSCRIBER
(
'0000000016',
'000008',
0752117991236829,
09,2017,422,
'N',
'Bi-yearly',
'03-Jan-2015'
);
INSERT INTO SUBSCRIBER
(
'0000000018',
'000009',
1234567899876543,
09,2017,422,
'N',
'3Year',
'20-Nov-2018'
);
INSERT INTO SUBSCRIBER
(
'0000000020',
'000010',
1234567899876543,
09,2017,422,
'N',
'1Year',
'20-Dec-2016'
);

VALUES

VALUES

VALUES

VALUES

SUBSCRIPTION TABLE
INSERT INTO SUBSCRIPTION
INSERT INTO SUBSCRIPTION
INSERT INTO SUBSCRIPTION
INSERT INTO SUBSCRIPTION
INSERT INTO SUBSCRIPTION
INSERT INTO SUBSCRIPTION
INSERT INTO SUBSCRIPTION

VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES

(000001,'M');
(000002,'M');
(000003,'M');
(000004,'M');
('000005','M');
('000006','M');
('000007','M');

33

INSERT INTO SUBSCRIPTION VALUES ('000008','Bi');


INSERT INTO SUBSCRIPTION VALUES ('000009','3Y');
INSERT INTO SUBSCRIPTION VALUES ('000010','Y');

34

Implemented Database Structure

This is the implementation model after it has already been created in the database management system.
This is different from the ER Diagram as can be referenced above because it only contains the many to
many relationships with the relations having their own attributes on the parent side.

Properties of Fields of Tables in Implemented Database

We needed to decipher what type of data would go in to each column of the


table, be it numerical, relating to time or data, alphanumerical, or other types
of data cases.
Table: Account Executive
EID = The identification number assigned to each executive.
ENAME = The name of the executive.
Table: Album
ALBID= The identification number assigned to each album.
ARTID= The identification number assigned to each artist.
ALBCOST= The price of the album.
ALBNAME= The name of the album.
GENRA= The genre that the album music lies within.
Table: Customer_Album
CUST_ALB= The identification number assigned to each customer album
interaction.
CID= The identification number assigned to each customer.
ALBID= The identification number assigned to each album.
PURCHASEALBUMTIME= The time and date when the customer purchases an
album.
Table: Artist
ARTID= The identification number assigned to each artist.
ARTNAME= The name of the artist.
Table: Contact
CID= The identification number assigned to each customer.
CONID= The identification number of each contact that was made.
CTYPE= The method by which the contact was made.
NOTIFICATION= The type of notification that was provided to the customer
when contacted.
Table: Customer
CID= The identification number assigned to each customer.
CTYPE= Whether or not the customer is a subscriber.
CSTREET= The street that the customer lives on.
CSTATE= The state that the customer lives in.
CZIP= The zipcode of the customers address.
CCITY= The city that the customer lives in.
CSIGNUP= When the customer signed up for their membership.
CDOB= The date of birth of the customer.
CEMAIL= The email address of the customer.
CNAME= The name of the customer.

Table: Customer_Song
CUSTSONG_ID= The identification number assigned to each customer song
interaction.
CID= The identification number assigned to each customer.
SONGID= The identification number of each song.
SONGRATING= The rating that the customers gave to the song.
SONGRATINGTIME= The time that the customer rated the song.
SONGTYPE= The type of song that the song is categorized as.
SONGSKIPTIMES= The amount of times that the song was skipped.
SONGUSAGEFREQUENCY= The frequency that the song was played.
LISTENINGTIME= The time that the customer listened to the song.
SKIPTIMEDATE= The time that the customer skipped the song.
Table: Customer_SongP
CSP_ID= The id number assigned to each song that is purchased by a
customer.
CID= The identification number assigned to each customer.
SONGID= The identification number of each song.
SONG_PRICE= The price of the individual song.
PURCHASETIME= The time that each song is purchased.
Table: Customer_Station
CUSTSTAT_ID= The id number assigned to each station listened to by a
customer.
CID= The identification number assigned to each customer.
ALBID= The identification number assigned to each album.
STATIONCREATIONTIME= The time that the station was created.
Table: Non_Subscriber
CID= The identification number assigned to each customer.
NSDURATION= The length of time that the trial lasts.
NSTARTDATE= The date that the trial was started.
NSENDATE= The date that the trial ends.
Table: Record Label
RID= The identification number assigned to the record label.
EID= The identification number assigned to the executive.
RECNAME= The name of the record.
PROFITRATIO= The profit ratio awarded to the record label.
Table: Song
SONGID= The identification number of each song.
ARTID= The identification number assigned to each artist.
RID= The identification number assigned to the record label.

37

SNAME= The name of the song.


SGENRA= The genre that the song is a part of.
SARTIST= The name of the artist that created the song.
SRELEASEDATE= The date that the song was released.
Table: Station
STATIONID= The identification number assigned to each station.
STARTTYPE= The number of stars given to each station.
Table: Station_Song
STATSONGID= The identification number assigned to each song and station
combination.
STATIONID= The identification number assigned to each station.
SONGID= The identification number assigned to each song.
Table: Subscriber
CID= The identification number assigned to each customer.
SUBSELECTID= The identification number associated with subscription type.
CCNUMBER= The credit card number of the customer.
CCEXPMONTH= The expiration month of the subscribers card.
CCEXPYEAR= The year that the subscribers card expires.
CCSECURITYCODE= The security code of the customers card.
CCPAYPALOPTION= Whether or not the customer is using PayPal.
SUBSCRIPTIONTYPE= The type of subscriber that the subscriber is whether
monthly yearly or bi-yearly.
SDURATION= The length of the subscription.
SENDDATE= The date that the payment information was processed.
Table: Subscription
SUBSELECTID= The identification number associated with subscription type.
SUBSCRIPTIONTYPE= The type of subscriber that the subscriber is whether
monthly yearly or bi-yearly.

38

Queries

In order to extract the data that was requested by MusicMash, the following
statements were crafted and subsequently ran. These statements are vital for
contributing to a MusicMash employees daily needs.
1. Most popular songs in a given month/year
SELECT Song.SongID,
Song.Sname,
Customer_Song.SONGUSAGEFRequency
FROM Song,
Customer_Song
WHERE Song.SongID=Customer_Song.SongID
AND Song.SongID IN
(SELECT SongID
FROM
(SELECT SONGID ,
SONGUSAGEFRequency ,
rank() over (order by SONGUSAGEFRequency DESC) AS rnk
FROM Customer_SONG
)
WHERE rnk <= 10
);
AND extract(MONTH FROM ListeningTime) =
&ListeningMonth
AND extract(YEAR FROM ListeningTime) =
&ListeningYear;
2. Most popular artists in a given month/year
SELECT Artist.ArtID,Artist.Artname,
Customer_Song.SONGUSAGEFRequency
FROM Song,
Customer_Song, Artist
WHERE Song.SongID=Customer_Song.SongID AND Song.ArtID =
Artist.ArtID
AND Song.SongID IN
(SELECT SongID
FROM
(SELECT SONGID ,
SONGUSAGEFRequency ,
rank() over (order by SONGUSAGEFRequency DESC) AS rnk
FROM Customer_SONG
)
WHERE rnk <= 10

39

)
AND extract(MONTH FROM ListeningTime) =
&ListeningMonth
AND extract(YEAR FROM ListeningTime) =
&ListeningYear;
3. Songs that are skipped most often by customers
SELECT SongID, SongSkiptimes
FROM
(SELECT SONGID ,
songskiptimes ,
rank() over (order by Songskiptimes DESC) AS rnk
FROM Customer_SONG
)
WHERE rnk <= &Howmanysongs;
4. Number of days until a trial expires for each trial customer
SELECT CID, SDuration, Round(senddate-sysdate) as
Numberofdaystillexpiration
FROM dual, subscriber
WHERE SDuration = 'TRIAL' AND Round(senddate-sysdate) >= 0;
5. An ordered list of the number of days until a subscription expires for paying
customers except monthly customers
SELECT CID, SDuration, Round(senddate-sysdate) as
Numberofdaystillexpiration
FROM dual, subscriber
WHERE SDuration <> 'TRIAL' AND SDuration <> '1MONTH' AND
Round(senddate-sysdate) >= 0
ORDER BY Numberofdaystillexpiration DESC;
6. Most popular categories of music by gender of the customer
SELECT Customer.Cgender, Customer_Song.songtype,
count(Customer_Song.songtype) as Most_Popular
FROM Customer, Customer_Song
WHERE Customer.CID = Customer_Song.CID AND Cgender = &Gender
GROUP BY Customer.Cgender, Customer_Song.songtype
ORDER BY count(Customer_Song.songtype) DESC;
7. Most popular song by region of the country

40

SELECT SongID, Customer_Song.Region, Max(Songusagefrequency) as


Most_Popular_Song
FROM Customer_Song
WHERE Region = &Region
GROUP BY Region,Songid
ORDER BY Most_Popular_Song DESC
FETCH NEXT 1 ROWS ONLY;
8. Monthly payments to record labels for purchased songs/albums.
SELECT cust_alb, Customer_SongP.SongID, Recordlabel.RID,
RecordLabel.Recname, Profitratio, cust_alb,
Sum(Song_Price) As Revenue, (Sum(Song_Price) *Profitratio) As
Monthly_Song_Payment, (Sum(Albcost)*.02) As
Monthly_Album_Payment
FROM Song, Customer_SongP, Recordlabel, Artist, Album,
Customer_Album
WHERE Customer_SongP.SongID = Song.SongID AND Song.RID =
Recordlabel.RID AND Song.ArtID = Artist.ArtID AND Album.ArtID =
Artist.ArtID AND Album.Albid = Customer_Album.Albid
AND extract(MONTH FROM PurchaseTime) = &PurchaseSongMonth AND
extract(MONTH FROM PurchaseTime) = &PurchaseAlbumMonth
GROUP BY Customer_SongP.SongID, Recordlabel.RID, Profitratio,
RecordLabel.Recname, albcost, cust_alb;
9. Monthly payment to account executives each month.
SELECT Customer_SongP.SongID, Recordlabel.RID, AccountExec.EID,
Profitratio, Sum(Song_Price) As Revenue, (Sum(Song_Price) *.02)
As Monthly_Payment_to_AccountEXEC
FROM Song, Customer_SongP, Recordlabel, AccountExec
WHERE Customer_SongP.SongID = Song.SongID AND Song.RID =
Recordlabel.RID AND Recordlabel.EID = AccountExec.EID
AND extract(MONTH FROM PurchaseTime) = &PurchaseMonth /*
isolates calculations for the month entered and user intuitively
knows month because they entered it*/
GROUP BY Customer_SongP.SongID, Recordlabel.RID,
AccountExec.EID, Profitratio;
10. Average price of music albums based on genre.
SELECT Genre, AVG(Albcost)
FROM ALBUM
GROUP BY Genre;
11. Average number of songs each customer listens to per day.

41

SELECT CID, AVG(AVGPERDAY) /*Aggregates all the average


songusagefrequencies per day and divides them by the total
number of days */
From Customer_SONG
WHERE CID IN
(
SELECT CID
FROM Customer_Song
WHERE ListeningTime >= ListeningTime - .5 AND ListeningTime <=
ListeningTime + .5
Return AVG (Songusagefrequency) as AVGPERDAY /*returning the
inner query for the average for each day, now we will add those
avgperday together and divide them by total to get total avg per
day */
);

42

User Documentation of Database

User documentation for the MusicMash database will be crafted by a


dedicated team of experts on the dataset. The documentation will instruct
MusicMash employees on how to use the service in the most efficient and
effective way possible. Advise the team of experts to include the following in
the user documentation for the database: (1) Managing Database Users, (2)
Modifying a Database Users Permissions with the Control Panel, (3) Changing
a Database Users Password, (4) Connecting to a Database, (5) Accessing a
Database from the Web, (6) Accessing a Database Remotely, (7) Import and
Export Database Records, (8) Running Queries.
Running queries will constitute a large part of what MusicMash employees will
be doing day in, day out. Weve included some documentation on what we
believe will be the most frequent use-case scenarios for queries.
1. Most popular songs in a given month/year
Run this query with the respective SQL code, listed above. The query will
prompt you to (1) Enter Value for ListeningMonth, which refers to the month
when the song was listened to by the user, and (2) Enter Value for
ListeningYear, which refers to the year when the song was listened to by the
user. This will return you the most popular songs in the time frame you
specified.
2. Most popular artists in a given month/year
Run this query with the respective SQL code, listed above. The query will
prompt you to (1) Enter Value for ListeningMonth, which refers to the month
when the artist was listened to by the user, and (2) Enter Value for
ListeningYear, which refers to the year when the artist was listened to by the
user. This will return you the most popular artists in the time frame you
specified.
3. Songs that are skipped most often by customers
Run this query with the respective SQL code, listed above. Running the
aforementioned query will prompt you to (1) Enter value for Howmanysong.
Entering this value will specify the quantity of top song skipped in descending
order. This will allow the database user to produce specific reports
(dashboards) for internal purposes.
4. Number of days until a trial expires for each trial customer

Run this query with the respective SQL code, listed above. Running the
aforementioned query will return the number of days until the trail expiries for
each trial customer. By include our WHERE statement, we have prevented
issues that may result from legacy data interfering with the current data in the
query. This also allows you to keep the legacy data in the database without
taking away from the queries you need to run for your business operation.
5. An ordered list of the number of days until a subscription expires for paying
customers except monthly customers
Run this query with the respective SQL code, listed above. Running the
aforementioned query will return an ordered list of the number of the days
until a subscription expires for paying customers except monthly customers.
By include our WHERE statement, we have prevented issues that may result
from legacy data interfering with the current data in the query. This also
allows you to keep the legacy data in the database without taking away from
the queries you need to run for your business operation.
6. Most popular categories of music by gender of the customer
Run this query with the respective SQL code, listed above. The query will
prompt you to (1) Enter Value for Gender, where Gender is defined as M, male,
or F, female. Be sure to when inputting male or female in quotes: M or F. A
common mistake is using double quotes (i.e. M or F) when inputting the
value. Running the aforementioned query will return the categories of music
by gender.
7. Most popular song by region of the country
Run this query with the respective SQL code, listed above. The query will
prompt you to (1) Enter Value for Region, where Region is defined as W,
West, N, North, E, East, S, South, NE, Northeast, NW, Northwest, SE,
Southeast, and SW, Southwest. The aforementioned query will return the
most popular song in your specified region of the country.
8. Monthly payments to record labels for purchased songs/albums.
Run this query with the respective SQL code, listed above. The query will
prompt you to (1) Enter value for PurchaseSongMonth, where
PurchaseSongMonth is the month in which the customer purchased the song
and (2) Enter value for PurchaseAlbumMonth, where PurchaseAlbmMonth is
the month in which the cusomter purchased the album. The values that you
are entering isolate your calculation for that specific month, allowing you to
find the monthly payment for songs or albums for that specific month.

44

Running the aforementioned query will return the monthly payments for
purchased songs and albums.
9. Monthly payment to account executives each month.
Run this query with the respective SQL code, listed above. The query will
prompt you to (1) Enter value for PurchaseMonth, where PurchaseMonth is the
month in which the songs were purchased that the account executive will get
paid for. Running the aforementioned query will return monthly payment to
account executives each month.
10. Average price of music albums based on genre.
Run this query with the respective SQL code, listed above. Running the
aforementioned query will return average price of music albums based on
genre
11. Average number of songs each customer listens to per day.
Run this query with the respective SQL code, listed above. Running the
aforementioned query will return the average number of songs each customer
listens to in the past (+/-) 12 hours.

Training and Use of Database

The SWOT team researched best practices at companies similar to MusicMash


to develop recommendations
The biggest database variable are the people using them. To overcome this,
training is required to use the database correctly and ensure people within the
company are best equip to use the database to its fullest potential. The last
thing your organization wants is for a new employee to break the database.
To have new hires hit the ground running, train them on the database by way
of (1) a seminar, (2) handouts, (3) restrict access, (4) provide opportunities for
further training.
A proven way to train employees is to have them learn by doing. Hold training
on-site seminarsbrining employees on in rotations if necessaryand explain
all aspects of the database. Emphasize the importance of quality assurance to
employees. Ensure the seminar concise and interactive, as the content and be
try at time and we want to keep employees engaged throughout the
seminars duration.
During your seminar, it may be useful to provide handouts to your employees
with key facts on the use of the database. Handouts will ensure that

45

employees will take notes on what you are saying, and give them something
to reference when they use the database following the training session. Make
the handout simple, clean, and concise.
Restrict employee access to only the parts of the database each individual
employee needs to access. We dont want to grant root access to all users.
Provide further opportunities for employees to expand their skill set with
respect to the database. Hold optional advanced seminars every 3 months to
allow for employees to grow. Grant employees access to existing Webinars
and courses (i.e. Lynda.com) so they can grow their knowledge as it suits
them, at their on pace, on their own time.

Technology Issues

A major technology issue we encountered at the start of Phase 3, was


remembering to save as we continued to work. We inserted all of our CREATE
TABLE statements and did not click the Commit Changes button when
quitting the SQL program. Therefore, when we logged back on to the
database we were surprised to see that all of our tables were missing. This
was a minor setback when working on our project, as we had to insert these
statements into the system once again.
One of the limitations we found when working with SQL was the ability to
only run the program when connected to UA Wi-Fi. This made it difficult as all
team members had to allocate time to meet up on campus to work on this
project, despite everyones busy scheduling. If SQL program could function
on other Wi-Fi networks, we would have more time to work on the project
and not be restricted to just working on it at school.
An addition problem that we ran into with SQL was the inability for multiple
users to be signed into the database. When this occurred the database would
either be extremely slow or constantly log out leaving the database useless
for both users. This would also happen if one user was using a VPN and
another user was on UAWIFI. The challenge with the aforementioned scenario
is that group members did not know when another member was logged in.
The last technology issue was the fact that some of our group members used
Mac and others used PC. SQL looks a little different on the two platforms
therefore it was difficult for group members to collaborate on each others
platform. Formatting was a huge issue combined with the google docs issue
and Macs inability to decipher proper apostrophes.

46

Lessons Learned

One of the most important lessons we learned over the course for the
semester while working on this project is the importance of attention to detail.
While imputing our SQL codes into the database, we encounter many errors.
A handful of these errors were caused simply because we did not pay close
enough attention when entering the sequences into the database. Forgetting
to add the semicolon after each statement and missing punctuations were
common mistakes we made at in the beginning. This was because we were
quickly entering the create table and insert statements while utilizing the
Google Docs application, where we had originally typed statements. When
copying and pasting these statements over, the formatting of them changed
as the functions in Mac OS X copy/paste function altered some of the
formatting. While we were trying to be time efficient in copying and pasting
multiple statements at a time, we actually spent more time trying to search
for where the error occurred in each line and correct the statement. Moving
forward, we learned to carefully type these statements directly into the
program to ensure we had the correct elements and formatting for each.
Once we nailed this down, we were able to efficiently enter the data.
The database itself was instrumental for learning lessons for the project. The
first lesson that SQL taught us was regarding foreign keys. A foreign key must
be added from an existing primary key in SQL. When we tried to correct this
issue by adding a second primary key, SQL will not allow it. After dropping
multiple tables and reinserting data we realized that the reason this foreign
kay could not be added was data redundancy. The data was redundant and
should have only been placed in one of our two tables. This second example
of how SQL taught us a lesson was in inserting the data. When we tried to
insert data we had to have more than 10 entries in the customer table. This is
because customers were later sub grouped into subscribers and non
subscribers. If we did not add more than 10 entries in our customer table, then
the subscriber and non subscriber tables would not have enough data per the
instructions of the assignment. This was easily rectified by the addition of 10
subscribers and 10 non subscribers in our customer table.

47

You might also like