1. Homepage
  2. Programming
  3. COMP1048 Databases and Interfaces - Coursework 2 - iMusic: Music Record Collection Website

COMP1048 Databases and Interfaces - Coursework 2 - iMusic: Music Record Collection Website

Engage in a Conversation
NottinghamCOMP1048Databases and InterfacesiMusicHTMLPythonFlaskJinjaCSSSQLite

iMusic: Music Record Collection Website CourseNana.COM

COMP1048, Databases and Interfaces: Coursework 2 CourseNana.COM

iMusic is a company that specialises in collecting and selling physical vinyl records. The company previously operated a physical store in the city center, but has recently decided to shift to an online-only business model. To reflect this change, they plan to update their website. They initially hired a professional developer to complete the work, but due to other commitments, the developer was unable to do so. Therefore, you have been hired to finish the project. CourseNana.COM

iMusic has provided you with a list of requirements for the website, which are outlined in the next sections. The website is partially implemented, and you are tasked with completing the implementation. CourseNana.COM

To complete the assignment, you only need to modify the iMusic.py file. The website makes use of the following technologies: CourseNana.COM

  • HTML - Is used for structuring and presenting the content of the iMusic website. HTML 5 is used for the website. CourseNana.COM

  • CSS - Is used for styling the content of the iMusic website. CSS 3 is used for the website. CourseNana.COM

  • Jinja - Is a templating language for Python, which is used to generate HTML pages for the iMusic website. During the testing of your solution, the iMusic team will use the CourseNana.COM

    3.0.3 version of Jinja. CourseNana.COM

  • Python 3 - Is a general-purpose programming language. During the testing of your CourseNana.COM

    solution, the iMusic team will use Python version 3.10 or later. You are advised to use the latest version of Python to complete the assignment. CourseNana.COM

    2 CourseNana.COM

  • Flask - A micro web application framework written in Python. During the testing of your solution, the iMusic team will use the 2.3.3 version of Flask. CourseNana.COM

  • SQLite - A relational database management system. During the testing of your solution, the iMusic team will use the 3.44.0 version of SQLite. CourseNana.COM

You are not permitted to use any other technologies or import any additional modules beyond those already imported in the iMusic.py file or those provided by the standard Python library. CourseNana.COM

Database Schema CourseNana.COM

The database for the project will store details of the vinyl records in the company’s inventory. It consists of four tables: CourseNana.COM

  • Artist: Stores the name of each artist. An artist is the person or group that performed the music on the record. CourseNana.COM

  • Album: Stores the title of each album and links to the artist that created the album. CourseNana.COM

  • Genre: A genre is a category that describes the type of music. This table stores the CourseNana.COM

    name of each available genre. CourseNana.COM

  • Track: A track represents a single song on a record. Each track is linked to an album CourseNana.COM

    and a genre. CourseNana.COM

    The Entity-Relationship diagram (ERD) in Figure 1 shows the relationships between the var- ious tables in the database. The developer has used a slightly different notation than the one presented in the lectures. However, you should use your professional knowledge and experience to interpret the diagram and understand the relationships between the tables. CourseNana.COM

    The database schema for the project is implemented in the iMusic.db file using the SQLite database engine. To complete the assignment, you must use this pre-existing schema and may not alter it in any way. CourseNana.COM

Figure 1: The iMusic record collection database schema CourseNana.COM

4 CourseNana.COM

Tasks CourseNana.COM

Task 1: Fix the Artist Table CourseNana.COM

Task Brief CourseNana.COM

In the process of developing the website, the developer made a mistake when inserting the name’s of Artists into the database. There was an unusual bug in the code that caused some (but not all) names to be entered incorrectly. You have been asked to fix the mistake by CourseNana.COM

updating the database with the correct names. CourseNana.COM

The previous developer managed to create the HTML template (templates/upload.html) for uploading a file, which contains the correct names of the artists, and added the URL /upload/ to the Flask application (iMusic.py) to handle the upload. However, they were unable to complete the implementation of the update functionality. CourseNana.COM

The form on the /upload/ page allows the user to upload a Tab-Separated Values (TSV) file containing the correct IDs and names of the artists. A TSV is a simple, plain text file that contains tab characters (\t) to separate columns of data. When the user uploads the TSV file, the existing code will save the file to the uploads/ directory with the name Artist.tsv. The TSV file contains the following columns: CourseNana.COM

ArtistId - The ID of the Artist. This is the primary key of the Artist table. • Name - The correct name of the artist for the given ArtistId. CourseNana.COM

The TSV file contains one row for each artist to be inserted or updated in the database. Once the file has been uploaded, the existing code will call the update_artist_table function, passing the path to the uploaded file as an argument. Inside the update_artist_table function, you will need to read the file and update the database with the correct names. To parse the TSV file, you should use the csv module from the Python standard library. To learn how to use the csv module, you should read the documentation (https://docs.python.org/3/ library/csv.html) - this is an expected part of the assignment. CourseNana.COM

Your task is to complete the implementation of the update_artist_table function. You must write the code that will read the file and update the database with the correct names. When implementing the update_artist_table function, you will need to consider the following: CourseNana.COM

• If the ArtistID already exists in the database, you must update the Name of the artist with the given ArtistId to the value provided in the TSV file. CourseNana.COM

• If the ArtistID does not exist in the database, you must insert a new artist with the given ArtistId and Name into the database. CourseNana.COM

Care is needed here - if you simply try to INSERT a new artist with the given ArtistId and Name, you will get an error because the ArtistId is the primary key of the Artist table (Uniqueness Constraint). There are a variety of ways to solve this problem, but the iMusic CourseNana.COM

5 CourseNana.COM

team aren’t sure which approach is best. You will need to decide how to solve this problem yourself. You may use any functionality supported by the SQLite version specified above. CourseNana.COM

There is no requirement to give feedback to the user about the success or failure of the operation, but you can if you’d like to. Further there is no requirement to handle errors or invalid data, but again, you can if you’d like to - it is good practice to do so. After the form is submitted and processed, you must redirect the user to the index page (/), regardless of whether the operation was successful or not. CourseNana.COM

When testing your implementation, the iMusic team will: CourseNana.COM

1. Visit the /upload/ page.
2. Upload a TSV file containing the correct artist names.
3. Submit the form.
4. Check that the
Artist table has been updated correctly, according to the contents of CourseNana.COM

the TSV file. CourseNana.COM

The iMusic team will not test your solution with invalid data. A sample TSV file containing the correct artist names have been provided in the data/ directory. You do not need to validate data in your solution or implement additional error checking or handling. CourseNana.COM

Your implementation must meet the following requirements: CourseNana.COM

Your implementation must be wholly contained within the update_artist_table function. You must not create any additional functions, or modify the tem- plate file in any way. CourseNana.COM

• Your implementation must run as a Flask application, which will be run using the com- mand python iMusic.py (or python3 iMusic.py). CourseNana.COM

• When interacting with the database, you must use the sqlite3 module. You cannot use any other modules or approaches (e.g. SQLAlchemy). CourseNana.COM

• When reading the TSV file, you must use the csv module. You are expected to read the documentation for the csv module to learn how to use it. You cannot use any other modules or approaches (e.g. Pandas). CourseNana.COM

Marking Criteria CourseNana.COM

Task 1 is worth 7 of the 25 marks available for the assignment. The following marking criteria will be used to assess your work: CourseNana.COM

ID Requirement
RQ1_1 Correct File Reading
CourseNana.COM

Details Marks CourseNana.COM

Successfully reads the TSV file using the 1 csv module, correctly parsing the
ArtistId and Name. CourseNana.COM

Requirement Database Connection CourseNana.COM

Correct Data Handling CourseNana.COM

Accurate Database Update
Accurate Database Insertion
CourseNana.COM

Details Marks CourseNana.COM

Establishes a connection to the SQLite 1 database using the sqlite3 module.
Correctly identifies whether an
ArtistId 1 exists in the database and decides to CourseNana.COM

update or insert data.
Accurately updates existing records in the 1.5 database with the correct artist names. Correctly inserts new records into the 1.5 database where
ArtistId does not exist. Correctly redirects the user to the index 1 page (‘/’) after the form is submitted. CourseNana.COM

Correct Redirection
Table 2: Marking Criteria for Task 1.
CourseNana.COM

Task 2: Genre Statistics Page CourseNana.COM

Task Brief CourseNana.COM

iMusic want an overview of the genres of music in their collection and the statistics associated with each genre. They have asked you to finish the implementation of the “Genre Statistics” page, for which the previous developer has already created a template (templates/statistics.html). A screenshot of the page is shown in Figure 2. The page contains a dropdown menu and a table. The dropdown menu is populated with the names of all genres in the database, in ascending order. The table should display the following, for the CourseNana.COM

selected genre: CourseNana.COM

  • Price - The average price of all tracks that have the selected Genre. The price should be rounded to two decimal places. CourseNana.COM

  • # Tracks - The number of tracks that have the selected Genre. CourseNana.COM

  • # Albums - The number of albums with at least one track in the selected Genre. CourseNana.COM

  • # Artists - The number of artists that have at least one track with the selected Genre. CourseNana.COM

  • Duration - The total duration of all tracks that have the selected Genre. The duration CourseNana.COM

    should be displayed in seconds, rounded to the nearest integer. CourseNana.COM

  • Total Value - The total value of all tracks that have the selected Genre. The value CourseNana.COM

    should be rounded two decimal places. CourseNana.COM

    Figure 2: A screenshot of an example output for Task 2. CourseNana.COM

    Users should be able to access the page by navigating to the /statistics/ URL, followed by the id of the selected genre. For example, to view the statistics for the genre with GenreId 1, the user would visit the URL /statistics/1/. Note, that there is a special case where the user can visit the URL /statistics/all/ to view the statistics for all genres in the database. The all case is not a genre in the database, but it should be handled correctly by your code. You should include all in the dropdown menu. When all is selected, the table should display the statistics for all genres in the database. CourseNana.COM

    When displaying the statistics for the specified genre, your code should render the statistics.html template. The template specifies a table, which should be populated with the statistics for the selected genre, as described above. The table will only ever contain one row. CourseNana.COM

    8 CourseNana.COM

The statistics displayed in the table will depend on the GenreId provided in the URL. If the specified GenreId does not exist in the database, then you should redirect the user to the statis- tics page (/statistics/) and display the error message: “The specified genre does not exist”. This error message should be displayed using the flash function and should be displayed in the warning style specified. An example of setting the display style (success, danger, warning among others) is shown below in the existing iMusic.py source code. Remember, when implementing this functionality, you also need to handle the special all case. CourseNana.COM

The functionality should be implemented in the file iMusic.py. The previous developer has already implemented the template for the page in the file templates/statistics.html, which you must not modify. When implementing the functionality, you will only need to modify the following functions in iMusic.py: CourseNana.COM

  • get_genres() - Retrieves a list of all genres from the database, and the special all genre, sorted in ascending order by name. CourseNana.COM

  • get_genre_statistics(genre_id) - Returns a list containing the statistics for the se- lected genre. The function will need to return values as specified in the template file. Must handle the special all case. CourseNana.COM

  • statistics(), statistics_genre(genre_id) and statistics_process() routing functions - These functions handle the routing for the /statistics/ URL. It’s likely that you’ll only need to modify statistics_process(). CourseNana.COM


    Requirement CourseNana.COM

Genre Data Retrieval CourseNana.COM

Genre Statistics Calculation CourseNana.COM

Handling of Special ‘All’ Case CourseNana.COM

Error Handling for Non-existent Genres CourseNana.COM

Details Marks CourseNana.COM

Correct implementation of get_genres() 1 to retrieve and return a list of all genres in ascending order. Includes the special ‘all’ case. CourseNana.COM

Accurate implementation of 3 get_genre_statistics(genre_id) to calculate and return the correct statistics
for a selected genre.
CourseNana.COM

Correct handling of the 2 /statistics/all/ URL to display
statistics for all genres.
Proper error handling and user redirection 1 with an appropriate message when a non-existent genre ID is requested.
CourseNana.COM

9 CourseNana.COM

ID Requirement CourseNana.COM

Details Marks CourseNana.COM

The code runs without errors, handling 1 web requests and database operations correctly. CourseNana.COM

Table 3: Marking Criteria for Task 2. CourseNana.COM

Error-Free Code Execution CourseNana.COM

Task 3: Add New Genre and Assign Tracks CourseNana.COM

iMusic is looking to diversify its collection by adding new musical genres and assigning tracks to these genres. Your task is to create a feature that allows the insertion of new genres into the Genre table and the assignment of tracks to these genres. This feature will be accessible through the /add/ URL. CourseNana.COM

The /add/ page presents a form for entering the name of a new genre and selecting tracks to be associated with this genre. The form has already been implemented in the templates/add.html template. You must complete the implementation of this page by writing the Python code that will handle the insertion of the new genre into the database and the assignment of selected tracks to this genre. CourseNana.COM

Your implementation should include the following functionalities: CourseNana.COM

Populate the Tracks CourseNana.COM

When the /add/ page is accessed, the select element in the form should be populated with the IDs and names of all tracks in the database without a genre, with items ordered by track name in ascending order. The track IDs and names should be retrieved from the database using the Track table. Tracks that already have a genre should not be included in the form. This functionality should be implemented in the get_tracks_with_no_genre() function, which should return a list of tuples containing the track IDs and names of all tracks without a genre. CourseNana.COM

Adding the New Genre CourseNana.COM

When a new genre name is submitted, your implementation must validate the name before inserting it into the database. You should only insert the new genre, iff: CourseNana.COM

• The genre name does not already exist in the database (uniqueness constraint). CourseNana.COM

Note, that your solution should be case sensitive, that is, “Rock” and “rock” are considered different genres. CourseNana.COM

• The genre name contains at least three characters and less than or equal to 120 characters. There are no limitations to the types of characters that can be used in the genre name. CourseNana.COM

If any of these conditions are not met, your code should not insert the genre into the database. Instead, it should redirect the user to the /add/ page with an error message informing the user that: “Problem with the provided genre name.”. This error message should be displayed using the flash function and should be displayed using the warning style. You should modify CourseNana.COM

the add_process() and add_genre_and_tracks(genre_name, track_ids) functions to implement this functionality. CourseNana.COM

Track Assignment CourseNana.COM

Along with the genre name, a list of track IDs may be submitted. There is no requirement for any tracks to be selected. That is, the user can submit the form without selecting any tracks. Your code must update these tracks in the Track table to associate them with the newly added genre. Track assignment should only proceed if: CourseNana.COM

• The genre name is valid, as per the conditions above.
• All submitted track IDs exist in the
Track table and do not already have a genre. CourseNana.COM

If any of these conditions are not met, your code should not update the tracks in the database. Instead, it should redirect the user to the /add/ page with an error message informing the user that: “The provided track IDs are invalid”. This error message should be displayed using the flash function and should be displayed in the warning style specified. Again, you will need to modify the add_process() and add_genre_and_tracks(genre_name, track_ids) functions to implement this functionality. CourseNana.COM

All or Nothing Approach CourseNana.COM

Your code should use an “all or nothing” approach when inserting the new genre and updating the tracks. That is, if any of the conditions above are not met, your code should not insert the new genre or update any of the tracks. For example, if the user submits a genre name that already exists in the database, your code should not update any of the tracks (or insert the new genre). Similarly, if the user submits a valid genre name, but an invalid track ID(s), your code should not insert the new genre or update any of the tracks. CourseNana.COM

Error Handling CourseNana.COM

Your solution should handle likely errors that may occur during the submission and processing of the form. Your code should be resilient to invalid inputs and operations. For all other errors, except those specified above, your code should redirect the user to the /add/ page with an error message informing the user that: “An error occurred while processing your request”. This error message should be displayed using the flash function and should be displayed with the warning style. CourseNana.COM

Here you will want to make use of the try and except statements to handle errors. You can read more about these statements in the Python documentation. CourseNana.COM

Redirecting the User After Successful Submission CourseNana.COM

After successful submission and processing, redirect the user to the index page (/) with a success message - “The genre has been added successfully”. This message should be displayed using the flash function, with the ‘success’ style. CourseNana.COM

Marking Criteria CourseNana.COM

Task 3 is worth 10 of the 25 marks available for the assignment. The following marking criteria will be used to assess your work: CourseNana.COM

ID RQ3_1 CourseNana.COM

RQ3_2 CourseNana.COM

RQ3_3 RQ3_4 CourseNana.COM

RQ3_5 RQ3_6 RQ3_7 CourseNana.COM

Requirement CourseNana.COM

Form Population with Tracks CourseNana.COM

Genre Name Validation CourseNana.COM

Database Insertion of New Genre
CourseNana.COM

Correctly populating the form with track 1 IDs and names from the database ordered
by name, excluding tracks already
assigned to a genre.
CourseNana.COM

Properly validating the new genre name 2 (uniqueness and character length CourseNana.COM

constraints).
Successfully inserting the new genre into 1 the database if all validation checks pass. Correctly validating the track IDs 1 submitted (existence in the database and
no prior genre assignment).
Accurately updating the database to 2 associate selected tracks with the new
genre.
Implementing the all or nothing approach 2 correctly, ensuring either all changes are committed or none if an error occurs.
Proper implementation of error handling 1 and providing appropriate user feedback
using the
flash function. CourseNana.COM

Table 4: Marking Criteria for Task 3. CourseNana.COM

Submission CourseNana.COM

To complete the assignment, you must submit an updated iMusic.py file containing your solutions to the tasks. No other files should be included in the submission. Ensure that your code is well commented and that you have included your name and student ID in the file. Additionally, ensure that you modify the functions specified in the assignment brief. You will need to submit your solution via Moodle by the deadline specified on the coursework issue sheet. CourseNana.COM

Penalties CourseNana.COM

Table 5 shows the penalties that apply to this assignment. CourseNana.COM

Penalties
Late Submission
CourseNana.COM

Incorrect Filename Use of Other Technologies CourseNana.COM

Details
Standard university penalty policy.
CourseNana.COM

The submitted filename must be ‘iMusic.py’.
Only the technologies specified in the assignment brief and the python standard library are allowed.
CourseNana.COM

Deduction CourseNana.COM

5% absolute deduction, per working day.
10% absolute deduction
CourseNana.COM

100% absolute deduction CourseNana.COM

Table 5: Penalties applicable to submissions. CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Nottingham代写,COMP1048代写,Databases and Interfaces代写,iMusic代写,HTML代写,Python代写,Flask代写,Jinja代写,CSS代写,SQLite代写,Nottingham代编,COMP1048代编,Databases and Interfaces代编,iMusic代编,HTML代编,Python代编,Flask代编,Jinja代编,CSS代编,SQLite代编,Nottingham代考,COMP1048代考,Databases and Interfaces代考,iMusic代考,HTML代考,Python代考,Flask代考,Jinja代考,CSS代考,SQLite代考,Nottinghamhelp,COMP1048help,Databases and Interfaceshelp,iMusichelp,HTMLhelp,Pythonhelp,Flaskhelp,Jinjahelp,CSShelp,SQLitehelp,Nottingham作业代写,COMP1048作业代写,Databases and Interfaces作业代写,iMusic作业代写,HTML作业代写,Python作业代写,Flask作业代写,Jinja作业代写,CSS作业代写,SQLite作业代写,Nottingham编程代写,COMP1048编程代写,Databases and Interfaces编程代写,iMusic编程代写,HTML编程代写,Python编程代写,Flask编程代写,Jinja编程代写,CSS编程代写,SQLite编程代写,Nottinghamprogramming help,COMP1048programming help,Databases and Interfacesprogramming help,iMusicprogramming help,HTMLprogramming help,Pythonprogramming help,Flaskprogramming help,Jinjaprogramming help,CSSprogramming help,SQLiteprogramming help,Nottinghamassignment help,COMP1048assignment help,Databases and Interfacesassignment help,iMusicassignment help,HTMLassignment help,Pythonassignment help,Flaskassignment help,Jinjaassignment help,CSSassignment help,SQLiteassignment help,Nottinghamsolution,COMP1048solution,Databases and Interfacessolution,iMusicsolution,HTMLsolution,Pythonsolution,Flasksolution,Jinjasolution,CSSsolution,SQLitesolution,