I have created a database for a college assessment, the assessment asks for a database od a CD collection and therefore information to be held on Discs, Artists and Songs and that at least one artist must have more than one disc in the database…………it states that I must be able to extract a list of all discs and songs by an artist who has more than one CD in the database.To this end I created three tables…………discs artists and songs……..each has a unique id primary key field and each has the other`s primary keys as foreign keys where appropriate, ie; the songs table has a songsid field a discid field an artistid field and songtitle field……the discs table has a discid field an artistid field and disctitle field the artists table has simply an artistid and artistname field…I need to know how to extract the a list of CD`s and songs by the one artist who has more than one CD in the database from the discs and songs tables…….so as I inserted an artist with two discs I am looking to extract the names of the two discs and the names of all the songs held on these two discs in one list by doing one query, sincere apologies if this appears as clear as mud , I have tried to give all details necessary but will give additional info if required. Tables creation syntax is as below :-
songs table
CREATE TABLE songs (
songid INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (songid),
discid INT,
artistid INT,
songtitle VARCHAR (60));
discs table
CREATE TABLE discs (
discid INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (discid),
cost DECIMAL (8,2),
disctitle VARCHAR (60),
releasedate DATE );
artists table
CREATE TABLE artists (
artistid INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (artistid),
artistname VARCHAR (60) );
Actual assessment question as below:-
You are required to design a database to store information about a music CD collection, Comprehensive information must be stored about Artists, CD`s and Songs.
You must fully document your design clearly showing all details of all tables, fields, field types, field sizes ,Primary and foreign keys, NOT NULL fields and all relationships in the database and populate with appropriate information. Use MySQL to implement your design, at least two of the CD`s must have been recorded by the same artist.
You must be able to extract the following information:
1. A list of all CD`s released before 1995.
2. A list of all CD`s and songs by one of the artists who has more than one CD in the collection.
3. The total cost of all the CD`s in the collection.