Assignment 11
Assignment 11
A record company wishes to use a computer database to help with its operations
regarding its performers, recordings and song catalogue. A requirements analysis
has elicited the following information: Songs have a unique song number, a non-
unique title and a composition date. A song can be written by a number of
composers; the composer’s full name is required. Songs are recorded by recording
artists (bands or solo performers). A song is recorded as a track of a CD. A CD has
many songs on it, called tracks. CDs have a unique record catalogue number, a title
and must have a producer(the full name of the producer is required). Each track
must have the recording date and the track number of the CD. A song can appear on
many (or no) CDs, and be recorded by many different recording artists. The same
recording artist might re-record the same song on different CDs. A CD must have
only 1 recording artist appearing on it. CDs can be released a number of times, and
each time the release date and associated number of sales is required.
INSERT ALL
INTO PRODUCER VALUES (1, 'Producer1')
INTO PRODUCER VALUES (2, 'Producer2')
INTO PRODUCER VALUES (3, 'Producer3')
INTO PRODUCER VALUES (4, 'Producer4')
INTO PRODUCER VALUES (5, 'Producer5')
SELECT * FROM DUAL;
INSERT ALL
INTO SONG VALUES (1, 'Song1', TO_DATE('01-01-2023', 'DD-MM-YYYY'))
INTO SONG VALUES (2, 'Song2', TO_DATE('15-12-2022', 'DD-MM-YYYY'))
INTO SONG VALUES (3, 'Song3', TO_DATE('20-02-2024', 'DD-MM-YYYY'))
INTO SONG VALUES (4, 'Song4', TO_DATE('10-05-2023', 'DD-MM-YYYY'))
INTO SONG VALUES (5, 'Song5', TO_DATE('30-11-2022', 'DD-MM-YYYY'))
SELECT * FROM DUAL;
INSERT ALL
INTO COMPOSER VALUES (1, 'Composer1')
INTO COMPOSER VALUES (2, 'Composer2')
INTO COMPOSER VALUES (3, 'Composer3')
INTO COMPOSER VALUES (4, 'Composer4')
INTO COMPOSER VALUES (5, 'Composer5')
SELECT * FROM DUAL;
INSERT ALL
INTO RECORDINGARTIST VALUES (1, 'Artist1')
INTO RECORDINGARTIST VALUES (2, 'Artist2')
INTO RECORDINGARTIST VALUES (3, 'Artist3')
INTO RECORDINGARTIST VALUES (4, 'Artist4')
INTO RECORDINGARTIST VALUES (5, 'Artist5')
SELECT * FROM DUAL;
INSERT ALL
INTO CD VALUES (1, 'CD1', 1, TO_DATE('01-01-2023', 'DD-MM-YYYY'), 1000)
INTO CD VALUES (2, 'CD2', 2, TO_DATE('15-02-2023', 'DD-MM-YYYY'), 1500)
INTO CD VALUES (3, 'CD3', 3, TO_DATE('20-03-2024', 'DD-MM-YYYY'), 1200)
INTO CD VALUES (4, 'CD4', 1, TO_DATE('15-12-2022', 'DD-MM-YYYY'), 800)
INTO CD VALUES (5, 'CD5', 2, TO_DATE('30-05-2023', 'DD-MM-YYYY'), 2000)
SELECT * FROM DUAL;
INSERT ALL
INTO SONGCOMPOSER VALUES (1, 1)
INTO SONGCOMPOSER VALUES (2, 2)
INTO SONGCOMPOSER VALUES (3, 3)
INTO SONGCOMPOSER VALUES (4, 4)
INTO SONGCOMPOSER VALUES (5, 5)
SELECT * FROM DUAL;
INSERT ALL
INTO SONGRECORDINGARTIST VALUES (1, 1)
INTO SONGRECORDINGARTIST VALUES (2, 2)
INTO SONGRECORDINGARTIST VALUES (3, 3)
INTO SONGRECORDINGARTIST VALUES (4, 4)
INTO SONGRECORDINGARTIST VALUES (5, 5)
SELECT * FROM DUAL;
INSERT ALL
INTO CDTRACK VALUES (1, 1, TO_DATE('01-01-2023', 'DD-MM-YYYY'), 1)
INTO CDTRACK VALUES (2, 1, TO_DATE('15-02-2023', 'DD-MM-YYYY'), 2)
INTO CDTRACK VALUES (3, 1, TO_DATE('20-03-2024', 'DD-MM-YYYY'), 3)
INTO CDTRACK VALUES (4, 1, TO_DATE('05-12-2022', 'DD-MM-YYYY'), 4)
INTO CDTRACK VALUES (5, 1, TO_DATE('30-05-2023', 'DD-MM-YYYY'), 5)
SELECT * FROM DUAL;
INSERT ALL
INTO CDRECORDINGARTIST VALUES (1, 1)
INTO CDRECORDINGARTIST VALUES (2, 2)
INTO CDRECORDINGARTIST VALUES (3, 3)
INTO CDRECORDINGARTIST VALUES (4, 4)
INTO CDRECORDINGARTIST VALUES (5, 5)
SELECT * FROM DUAL;
SQL:-
i>Update number of recorded album to 4 for those artist who has recorded only 3.
PL/SQL
i>Write Procedure to insert a new Contract into the Contract relation.
CREATE OR REPLACE PROCEDURE INSERTCONTRACT (CID IN NUMBER, AID
IN NUMBER, COMP IN NUMBER) AS
BEGIN
INSERT INTO CONTRACT VALUES(CID,AID,COMP);
COMMIT;
END;
/