We
have to design a database to collect these large volumes of data which is
happening in manual system for better decisions and analyze in future to be
achieved the goal.
-- Database: 'notown'
-- Table structure
for table 'album'
CREATE TABLE IF NOT
EXISTS 'album' (
'AlbumID' varchar(10) NOT NULL,
'Title' varchar(150) NOT NULL,
'CopyrightDate' date NOT NULL,
'Format' varchar(10) NOT NULL,
'length' time NOT NULL,
'SSN' int(11) NOT NULL,
'comment' varchar(100) NOT NULL,
PRIMARY KEY ('AlbumID')
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'group'
CREATE TABLE IF NOT
EXISTS 'group' (
'GroupID' varchar(10) NOT NULL,
'Name' varchar(150) NOT NULL,
PRIMARY KEY ('GroupID')
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'group_perform_song'
CREATE TABLE IF NOT
EXISTS 'group_perform_song' (
'GroupID' varchar(10) NOT NULL,
'SongID' varchar(10) NOT NULL,
'Date' date NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'group_release_album'
CREATE TABLE IF NOT
EXISTS 'group_release_album' (
'AlbumID' varchar(10) NOT NULL,
'groupID' varchar(10) NOT NULL,
'date' date NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'instruments'
CREATE TABLE IF NOT
EXISTS 'instruments' (
'Name' varchar(150) NOT NULL,
'MusicalKey' varchar(250) NOT NULL,
PRIMARY KEY ('Name')
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'musician'
CREATE TABLE IF NOT
EXISTS 'musician' (
'SSN' int(11) NOT NULL,
'Name' varchar(150) NOT NULL,
'Address' varchar(250) NOT NULL,
'Contact' varchar(10) NOT NULL,
PRIMARY KEY ('SSN')
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'musician_contact'
CREATE TABLE IF NOT
EXISTS 'musician_contact' (
'SSN' int(11) NOT NULL,
'Contact 1' varchar(10) NOT NULL,
'Contact 2' varchar(10) NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'musician_join_group'
CREATE TABLE IF NOT
EXISTS 'musician_join_group' (
'GroupID' varchar(10) NOT NULL,
'SSN' int(11) NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'musician_play_instrument'
CREATE TABLE IF NOT
EXISTS 'musician_play_instrument' (
'SSN' int(11) NOT NULL,
'Name' varchar(150) NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'producer'
CREATE TABLE IF NOT
EXISTS 'producer' (
'SSN' int(11) NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'producer_record_song'
CREATE TABLE IF NOT
EXISTS 'producer_record_song' (
'SSN' int(11) NOT NULL,
'SongID' varchar(10) NOT NULL,
'date' date NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'release_group'
CREATE TABLE IF NOT
EXISTS 'release_group' (
'GroupID' varchar(10) NOT NULL,
'Type' varchar(25) NOT NULL
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
-- Table structure
for table 'songs'
REATE TABLE IF NOT
EXISTS 'songs' (
'SongID' varchar(10) NOT NULL,
'Title' varchar(150) NOT NULL,
'Author' varchar(100) NOT NULL,
PRIMARY KEY ('SongID')
) ENGINE=InnoDB
DEFAULT CHARSET=latin1;
ALTER TABLE ' release_group '
ADD CONSTRAINT ' groupid _fk' FOREIGN KEY (' groupid ') REFERENCES 'group'
(' groupid ');
ALTER TABLE ' group_ release_album '
ADD CONSTRAINT ' groupid_fk' FOREIGN KEY (' groupid ') REFERENCES 'group
(' groupid ');
ALTER TABLE ' group_ release_album '
ADD CONSTRAINT ' albumid_fk' FOREIGN KEY (' albumid ') REFERENCES 'album'
(' albumid ');
ALTER TABLE ' musician_join_group'
ADD CONSTRAINT ' groupid_fk' FOREIGN KEY (' groupid ') REFERENCES 'group'
(' groupid ');
ALTER TABLE ' producer_record_song'
ADD CONSTRAINT ' songid_fk' FOREIGN KEY (' songid ') REFERENCES 'song'
(' songid ');
ALTER TABLE ' producer_record_song'
ADD CONSTRAINT ' ssn_fk' FOREIGN KEY (' ssn ') REFERENCES 'producer' ('ssn
');
ALTER TABLE ' group_perform_song'
ADD CONSTRAINT ' songid_fk1' FOREIGN KEY (' songid ') REFERENCES 'song'
(' songid ');
ALTER TABLE ' group_perform_song''
ADD CONSTRAINT ' groupid_fk1' FOREIGN KEY (' groupid ') REFERENCES 'group'
(' groupid ');
ALTER TABLE ' musician_contact’
ADD CONSTRAINT ' ssn_fk1' FOREIGN KEY (' ssn') REFERENCES 'musician' (' ssn');
ALTER TABLE ' musician_play_instrument’
ADD CONSTRAINT ' ssn_fk2' FOREIGN KEY (' ssn') REFERENCES 'musician' (' ssn');
-- Dumping data for
table 'group'
INSERT INTO 'group'
('GroupID', 'Name') VALUES
('G001', 'nelum'),
('G002', 'Olu'),
('G003', 'Manel'),
('G004', 'Pichcha'),
('G005', 'Saman');
-- Dumping data for
table 'group_perform_song'
INSERT INTO
'group_perform_song' ('GroupID', 'SongID', 'Date') VALUES
('G001', 'S001',
'2018-01-15'),
('G002', 'S002',
'2018-01-03'),
('G003', 'S003',
'2018-01-07'),
('G004', 'S004',
'2018-01-12'),
('G005', 'S005',
'2018-01-04');
-- Dumping data for
table 'group_release_album'
INSERT INTO
'group_release_album' ('AlbumID', 'groupID', 'date') VALUES
('A001', 'G001',
'2018-01-24'),
('A002', 'G002',
'2018-01-31'),
('A003', 'G003',
'2018-01-28'),
('A004', 'g004',
'2018-01-29'),
('A005', 'G005',
'2018-01-25');
-- Dumping data for
table 'instruments'
INSERT INTO
'instruments' ('Name', 'MusicalKey') VALUES
('Box Guitar', 'A'),
('Flute', 'E-Flat'),
('Guitar',
'C-Flat'),
('Organ', 'F-Flat'),
('Sithar', 'F'),
('Violin', 'D');
-- Dumping data for
table 'musician'
INSERT INTO
'musician' ('SSN', 'Name', 'Address', 'Contact') VALUES
(1201, 'sumith',
'apura', ''),
(1202, 'bandara',
'ratnapura', ''),
(1203, 'kumara',
'matale', ''),
(1204, 'sandali',
'colombo', ''),
(1205, 'saduni',
'gampaha', '');
-- Dumping data for
table 'musician_contact'
INSERT INTO
'musician_contact' ('SSN', 'Contact 1', 'Contact 2') VALUES
(1201, '0774551122',
'0713233333'),
(1202, '0754444122',
'0714854452'),
(1203, '0725535512',
'0715545525'),
(1204, '0714444555',
'0774555211'),
(1205, '0716666651',
'0778855451');
-- Dumping data for
table 'album'
INSERT INTO 'album'
('AlbumID', 'Title', 'CopyrightDate', 'Format', 'length', 'SSN', 'comment')
VALUES
('A001', 'Sada
Tharuwa', '2018-01-16', 'wav', '45:00:00', 1201, 'good suond'),
('A002', 'hada
paluwa', '2018-01-01', 'wav', '48:00:00', 1202, 'best'),
('A003', 'thaniwee',
'2018-01-05', 'mp3', '02:50:00', 1203, 'better'),
('A004', 'Nihada
raa', '2018-01-04', 'wav', '90:00:00', 1204, 'high gain'),
('A005', 'obage
pema', '2018-01-14', 'mp3', '02:45:20', 1205, 'bad');
-- Dumping data for
table 'songs'
INSERT INTO 'songs'
('SongID', 'Title', 'Author') VALUES
('S001', 'madhu
mala', 'milton perera'),
('S002', 'obe nil
nuwan', 'milton perera'),
('S003', 'obe
kadulu', 'neela wicramasinghe'),
('S004', 'ahal mal',
'chandana liyanaarchchi'),
('S005', 'parami
dam', 'neela wicramasinghe');
-- Dumping data for
table 'release_group'
INSERT INTO
'release_group' ('GroupID', 'Type') VALUES
('G001', 'RELEASE
GROUP'),
('G002', 'OTHER
GROUP'),
('G004', 'RELEASE
GROUP'),
('G003', 'OTHER
GROUP'),
('G005', 'RELEASE
GROUP');
-- Dumping data for
table 'producer_record_song'
INSERT INTO
'producer_record_song' ('SSN', 'SongID', 'date') VALUES
(1201, 'S001',
'2017-12-12'),
(1202, 'S002',
'2017-12-04'),
(1203, 'S003',
'2017-12-18'),
(1204, 'S004',
'2017-12-18'),
(1205, 'S005',
'2017-11-28');
-- Dumping data for
table 'producer'
INSERT INTO
'producer' ('SSN') VALUES
(1201),
(1202),
(1203),
(1204),
(1205);
-- Dumping data for
table 'musician_play_instrument'
INSERT INTO
'musician_play_instrument' ('SSN', 'Name') VALUES
(1201, 'Box
Guitar'),
(1202, 'Flute'),
(1203, 'Violin'),
(1204, 'organ'),
(1205, 'Box
Guitar');
-- Dumping data for
table 'musician_join_group'
INSERT INTO
'musician_join_group' ('GroupID', 'SSN') VALUES
('G001', 1201),
('G002', 1202),
('G003', 1203),
('G004', 1204),
('G005', 1205);
No comments:
Post a Comment