Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Unix help please You will build the program part by part, incrementally along wi

ID: 3760136 • Letter: U

Question

Unix help please

You will build the program part by part, incrementally along with one or two quick-fix program(s) to do the required task. You should submit in a zip file containing: (1) your document (this file with your documentation – program listings, the screenshots of compile and run), (2) all the programs (source and executable), and (3) database file (song.db).

Your document (attached in this file) should present your work professionally and thoroughly to help TA in grading, first by reading through this document.

If your codes are not running in cs1, then it receives 0 for that part, by default.

If your code should be compiled by TA to be tested, there will be 10% - 30% penalty based on each case.

Project description.

Music-Shop has many CDs and its CD listing in a database (named "song.db") with sqlite3. The database maintains three tables of artist, cd and track of each cd. Each cd has many tracks. Each track has a song (song title) of an artist. The schema and sample listings of these tables are shown below.

create table cd (

      id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,

      title VARCHAR(70) NOT NULL,      

      artist_id INTEGER NOT NULL,

      catalogue VARCHAR(30) NOT NULL

);

create table artist (

      id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,

      name VARCHAR(100) NOT NULL

);

create table track (

      cd_id INTEGER NOT NULL,

      track_id INTEGER NOT NULL,

      title VARCHAR(70),

      PRIMARY KEY(cd_id, track_id)

);

One day the database was damaged and unrecoverable. Fortunately, someone saved a file of all the records a few days before the crash (as shown below where each field is separated by "|").

sqlite> select * from artist;

1|Pink Floyd

2|Genesis

3|Einaudi

4|Melanie C

sqlite> select * from cd;

1|Dark Side of the Moon|1|B000024D4P

2|Wish You Were Here|1|B000024D4S

3|A Trick of the Tail|2|B000024EXM

4|Selling England By the Pound|2|B000024E9M

5|I Giorni|3|B000071WEV

6|Northern Star|4|B00004YMST

sqlite> select * from track;

1|1|Speak to me

1|2|Breathe

1|3|On the run

1|4|Time

1|5|Great gig in the sky

1|6|Mooney

1|7|Us and them

1|8|Any colour you like

1|9|Brain damage

1|10|Eclipse

2|1|Shine on you crazy diamond

2|2|Welcome to the machine

2|3|Have a cigar

2|4|Wish you were here

2|5|Shine on you crazy diamond pt.2

3|1|Dance on a volcano

3|2|Entangled

3|3|Squonk

3|4|Madman moon

3|5|Robbery assault and battery

3|6|Ripples

3|7|Trick of the tail

3|8|Los Endos

4|1|Melodia Africana (part 1)

4|2|I due fiumi

4|3|In unaltra vita

4|4|Melodia Africana (part 2)

4|5|Stella del mattino

4|6|I giorni

4|7|Samba

4|8|Melodia Africana (part 3)

4|9|La nascita delle cose segrete

4|10|Quel che resta

4|11|Inizio

4|12|Limbo

4|13|Bella notte

4|14|Canzone Africana (part 4)

6|1|Go!

6|2|Northern Star

6|3|Goin Down

6|4|I Turn To You

6|5|If That Were Me

6|6|Never Be The Same Again

6|7|Why

6|8|Suddenly Monday

6|9|Ga Ga

6|10|Be The One

6|11|Closer

6|12|Feel The Sun

The shop-manager wants you (IT consultant) to do a project, to create a software system (using C++ with sqlite3 database) to restore the lost database. Your job is to write a C++ program to do the following tasks.

Your C++ program will do (interacting with sqlite3 database, named "song.db" which is initially empty). This is done by "touch song.db" to create an empty file.

Part 1.

(A1) You need to create the files of artist, cd, and track (as shown above).

To read the file and tokenize each line to get each field data.

(A2) Use it (from (1)) to create sql statement(s) to be used to call the database, to create the tables and then to insert each record (one by one, or all at once for each table). For each record, for example, the first record for track

1|1|Speak to me

         should be a sql insert statement to be used for the program to interact with the database, to insert a record

insert into track(cd_id, track_id, title) values(1, 1, 'Speak to me');

(A3) To get the records from the database tables, and to output (print) each record to a file, after (p2) is done. The output should include a proper heading for each table and formatting for each record to be printed into an output file. You may use select statement to get all the records of a table (for example, "select * from artist;" to get all the records from artist table).

(A4) After all done, someone discovered one typo in the record.

You will write a small quick-fix C++ program, to correct this typo in the record in the database as shown below. With update sql call, the song title should be updated to "Money" (not "Mooney"). After it is corrected, get the record from the database and print it. You may use select statement to get all the records of the track table (for example, "select * from track;" to get all the records from track table) to show the record has been corrected.

1|6|Mooney   which should be 1|6|Money

      You may need to call sqlite3 to do this update: update track set title = 'money' where cd_id=1 and track_id=6;

(A5) To delete all the records in the tables of the database, to clean up.

Part2.

(B1) to design and implement three classes (artist, cd, track) corresponding to each table (artist, cd, track).

(B2) to get the data from the database to create (instantiate) each object corresponding to each record (from each table: artist, cd, and track). For example, for each artist record, its object (of each artist) will be created and initialized accordingly. After each class and its objects created, the program will generate a report for this class and all the objects of each class.

(B3) to use a C++ STL map (associative container), the created objects (of each class) should be kept in record so that you may enumerate (iterate) each object of artist class, or to search an artist object with artist id, etc.

      See some examples of how to create a map and use of map iterator. You may use "static" keyword to keep the instance of a map to be static.   

(B4) After creating all the objects (of artist, cd, and track), the program will check the integrity of the data (the objects). For example, each cd object has a field (variable) for an artist id. That is, the corresponding artist object (of this artist id defined in a cd object) should be created and exist. The program will check the integrity and produce a report of any exception (missing data) or to state, for example, that the artist id in one cd object is checked. Each integrity check will be implemented via a method of each class.

      For example, you will have a method (getArtist) in the cd class to get the corresponding artist object (a reference to the object) with the artist id specified in that particular cd object (to verify the data or object integrity with the artist object with the artist id in question). For example, getArtist(int artistID) call where artistID = 1, will return the reference to the artist object of which artist id = 1. If the artist object is not existed then return a null pointer (to indicate an exception).

      Current data is in integrity.

Next update your program to insert a track record (below) to create an exception.

7|Northern Star|5|B00004YMST

      This will create an integrity problem for there is no artist id which is 5.

      Run your program to generate the exception report for this case.

--- Hint for SQL statements for your program to generate from the data.

--- First the artist (or group) tables

insert into artist(id, name) values(1, 'Pink Floyd');

insert into artist(id, name) values(2, 'Genesis');

insert into artist(id, name) values(3, 'Einaudi');

insert into artist(id, name) values(4, 'Melanie C');

--- Then the cd table

insert into cd(id, title, artist_id, catalogue) values(1, 'Dark Side of the Moon', 1, 'B000024D4P');

insert into cd(id, title, artist_id, catalogue) values(2, 'Wish You Were Here', 1, 'B000024D4S');

insert into cd(id, title, artist_id, catalogue) values(3, 'A Trick of the Tail', 2, 'B000024EXM');

insert into cd(id, title, artist_id, catalogue) values(4, 'Selling England By the Pound', 2, 'B000024E9M');

insert into cd(id, title, artist_id, catalogue) values(5, 'I Giorni', 3, 'B000071WEV');

insert into cd(id, title, artist_id, catalogue) values(6, 'Northern Star', 4, 'B00004YMST');

--- Finally we populate the track

insert into track(cd_id, track_id, title) values(1, 1, 'Speak to me');

insert into track(cd_id, track_id, title) values(1, 2, 'Breathe');

insert into track(cd_id, track_id, title) values(1, 3, 'On the run');

insert into track(cd_id, track_id, title) values(1, 4, 'Time');

insert into track(cd_id, track_id, title) values(1, 5, 'Great gig in the sky');

insert into track(cd_id, track_id, title) values(1, 6, 'Mooney');

insert into track(cd_id, track_id, title) values(1, 7, 'Us and them');

insert into track(cd_id, track_id, title) values(1, 8, 'Any colour you like');

insert into track(cd_id, track_id, title) values(1, 9, 'Brain damage');

insert into track(cd_id, track_id, title) values(1, 10, 'Eclipse ');

insert into track(cd_id, track_id, title) values(2, 1, 'Shine on you crazy diamond');

insert into track(cd_id, track_id, title) values(2, 2, 'Welcome to the machine');

insert into track(cd_id, track_id, title) values(2, 3, 'Have a cigar');

insert into track(cd_id, track_id, title) values(2, 4, 'Wish you were here');

insert into track(cd_id, track_id, title) values(2, 5, 'Shine on you crazy diamond pt.2');

insert into track(cd_id, track_id, title) values(3, 1, 'Dance on a volcano');

insert into track(cd_id, track_id, title) values(3, 2, 'Entangled');

insert into track(cd_id, track_id, title) values(3, 3, 'Squonk');

insert into track(cd_id, track_id, title) values(3, 4, 'Madman moon');

insert into track(cd_id, track_id, title) values(3, 5, 'Robbery assault and battery');

insert into track(cd_id, track_id, title) values(3, 6, 'Ripples');

insert into track(cd_id, track_id, title) values(3, 7, 'Trick of the tail');

insert into track(cd_id, track_id, title) values(3, 8, 'Los Endos');

insert into track(cd_id, track_id, title) values(4, 1, 'Melodia Africana (part 1)');

insert into track(cd_id, track_id, title) values(4, 2, 'I due fiumi');

insert into track(cd_id, track_id, title) values(4, 3, 'In unaltra vita');

insert into track(cd_id, track_id, title) values(4, 4, 'Melodia Africana (part 2)');

insert into track(cd_id, track_id, title) values(4, 5, 'Stella del mattino');

insert into track(cd_id, track_id, title) values(4, 6, 'I giorni');

insert into track(cd_id, track_id, title) values(4, 7, 'Samba');

insert into track(cd_id, track_id, title) values(4, 8, 'Melodia Africana (part 3)');

insert into track(cd_id, track_id, title) values(4, 9, 'La nascita delle cose segrete');

insert into track(cd_id, track_id, title) values(4, 10, 'Quel che resta');

insert into track(cd_id, track_id, title) values(4, 11, 'Inizio');

insert into track(cd_id, track_id, title) values(4, 12, 'Limbo');

insert into track(cd_id, track_id, title) values(4, 13, 'Bella notte');

insert into track(cd_id, track_id, title) values(4, 14, 'Canzone Africana (part 4)');

insert into track(cd_id, track_id, title) values(6, 1, 'Go!');

insert into track(cd_id, track_id, title) values(6, 2, 'Northern Star');

insert into track(cd_id, track_id, title) values(6, 3, 'Goin Down');

insert into track(cd_id, track_id, title) values(6, 4, 'I Turn To You');

insert into track(cd_id, track_id, title) values(6, 5, 'If That Were Me');

insert into track(cd_id, track_id, title) values(6, 6, 'Never Be The Same Again');

insert into track(cd_id, track_id, title) values(6, 7, 'Why');

insert into track(cd_id, track_id, title) values(6, 8, 'Suddenly Monday');

insert into track(cd_id, track_id, title) values(6, 9, 'Ga Ga');

insert into track(cd_id, track_id, title) values(6, 10, 'Be The One');

insert into track(cd_id, track_id, title) values(6, 11, 'Closer');

insert into track(cd_id, track_id, title) values(6, 12, 'Feel The Sun');

Explanation / Answer

create table cd (

      id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,

      title VARCHAR(70) NOT NULL,      

      artist_id INTEGER NOT NULL,

      catalogue VARCHAR(30) NOT NULL

);

Excute in this type of code

create table artist (

      id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,

      name VARCHAR(100) NOT NULL

);

create table track (

      cd_id INTEGER NOT NULL,

      track_id INTEGER NOT NULL,

      title VARCHAR(70),

      PRIMARY KEY(cd_id, track_id)

)

--- First the artist (or group) tables

insert into artist(id, name) values(1, 'Pink Floyd');

insert into artist(id, name) values(2, 'Genesis');

insert into artist(id, name) values(3, 'Einaudi');

insert into artist(id, name) values(4, 'Melanie C');

--- Then the cd table

insert into cd(id, title, artist_id, catalogue) values(1, 'Dark Side of the Moon', 1, 'B000024D4P');

insert into cd(id, title, artist_id, catalogue) values(2, 'Wish You Were Here', 1, 'B000024D4S');

insert into cd(id, title, artist_id, catalogue) values(3, 'A Trick of the Tail', 2, 'B000024EXM');

insert into cd(id, title, artist_id, catalogue) values(4, 'Selling England By the Pound', 2, 'B000024E9M');

insert into cd(id, title, artist_id, catalogue) values(5, 'I Giorni', 3, 'B000071WEV');

insert into cd(id, title, artist_id, catalogue) values(6, 'Northern Star', 4, 'B00004YMST');

--- Finally we populate the track

insert into track(cd_id, track_id, title) values(1, 1, 'Speak to me');

insert into track(cd_id, track_id, title) values(1, 2, 'Breathe');

insert into track(cd_id, track_id, title) values(1, 3, 'On the run');

insert into track(cd_id, track_id, title) values(1, 4, 'Time');

insert into track(cd_id, track_id, title) values(1, 5, 'Great gig in the sky');

insert into track(cd_id, track_id, title) values(1, 6, 'Mooney');

insert into track(cd_id, track_id, title) values(1, 7, 'Us and them');

insert into track(cd_id, track_id, title) values(1, 8, 'Any colour you like');

insert into track(cd_id, track_id, title) values(1, 9, 'Brain damage');

insert into track(cd_id, track_id, title) values(1, 10, 'Eclipse ');

insert into track(cd_id, track_id, title) values(2, 1, 'Shine on you crazy diamond');

insert into track(cd_id, track_id, title) values(2, 2, 'Welcome to the machine');

insert into track(cd_id, track_id, title) values(2, 3, 'Have a cigar');

insert into track(cd_id, track_id, title) values(2, 4, 'Wish you were here');

insert into track(cd_id, track_id, title) values(2, 5, 'Shine on you crazy diamond pt.2');

insert into track(cd_id, track_id, title) values(3, 1, 'Dance on a volcano');

insert into track(cd_id, track_id, title) values(3, 2, 'Entangled');

insert into track(cd_id, track_id, title) values(3, 3, 'Squonk');

insert into track(cd_id, track_id, title) values(3, 4, 'Madman moon');

insert into track(cd_id, track_id, title) values(3, 5, 'Robbery assault and battery');

insert into track(cd_id, track_id, title) values(3, 6, 'Ripples');

insert into track(cd_id, track_id, title) values(3, 7, 'Trick of the tail');

insert into track(cd_id, track_id, title) values(3, 8, 'Los Endos');

insert into track(cd_id, track_id, title) values(4, 1, 'Melodia Africana (part 1)');

insert into track(cd_id, track_id, title) values(4, 2, 'I due fiumi');

insert into track(cd_id, track_id, title) values(4, 3, 'In unaltra vita');

insert into track(cd_id, track_id, title) values(4, 4, 'Melodia Africana (part 2)');

insert into track(cd_id, track_id, title) values(4, 5, 'Stella del mattino');

insert into track(cd_id, track_id, title) values(4, 6, 'I giorni');

insert into track(cd_id, track_id, title) values(4, 7, 'Samba');

insert into track(cd_id, track_id, title) values(4, 8, 'Melodia Africana (part 3)');

insert into track(cd_id, track_id, title) values(4, 9, 'La nascita delle cose segrete');

insert into track(cd_id, track_id, title) values(4, 10, 'Quel che resta');

insert into track(cd_id, track_id, title) values(4, 11, 'Inizio');

insert into track(cd_id, track_id, title) values(4, 12, 'Limbo');

insert into track(cd_id, track_id, title) values(4, 13, 'Bella notte');

insert into track(cd_id, track_id, title) values(4, 14, 'Canzone Africana (part 4)');

insert into track(cd_id, track_id, title) values(6, 1, 'Go!');

insert into track(cd_id, track_id, title) values(6, 2, 'Northern Star');

insert into track(cd_id, track_id, title) values(6, 3, 'Goin Down');

insert into track(cd_id, track_id, title) values(6, 4, 'I Turn To You');

insert into track(cd_id, track_id, title) values(6, 5, 'If That Were Me');

insert into track(cd_id, track_id, title) values(6, 6, 'Never Be The Same Again');

insert into track(cd_id, track_id, title) values(6, 7, 'Why');

insert into track(cd_id, track_id, title) values(6, 8, 'Suddenly Monday');

insert into track(cd_id, track_id, title) values(6, 9, 'Ga Ga');

insert into track(cd_id, track_id, title) values(6, 10, 'Be The One');

insert into track(cd_id, track_id, title) values(6, 11, 'Closer');

insert into track(cd_id, track_id, title) values(6, 12, 'Feel The Sun');

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote