Overview
This assignment helps you practice more SQL statements that manipulate the database, such as insert, update, and deleting records. You will write eleven SQL statements: five for Song database and six for DVD database.
Requirements
Create one .sql
file for all eleven SQL statements. Use comments to write the prompt above each SQL statement.
Part 1 – Song Database
- Create a view
mpeg_tracks
that displays all tracks with MPEG audio file format. Display track name (track_name
) artist name (artist_name
), composer, album title (album_title
), and media type (media_type
). Sort results in alphabetical order by track name.
- Add a track below to the database:
- Track Title: The Ocean
- Album: The Song Remains The Same (Disc 1)
- Artist: Led Zeppelin
- Media Type: MPEG audio file
- Genre: Rock
- Composer: John Bonham/John Paul Jones/Robert Plant
- Milliseconds: 248000
- Bytes: 7990000
- Unit Price: 0.99
- Make the following changes to the track added above:
New Bytes: 8998765
New Unit Price: 1.99 - Delete track “20 Flight Rock” by BackBeat from the database.
- Display how many tracks there are for each album. Show album ID, album title (
album_title
), and track count (track_count
).- Note: some of your counts might be different due to added or deleted records during in-class exercises.
- Note: some of your counts might be different due to added or deleted records during in-class exercises.
Part 2 – DVD Database
- Create a view
dramas
that displays all drama DVDs with release date not set to NULL. Show DVD ID, DVD title, release date, award, format, genre, label, rating, and sound.
- Add a new DVD with the below information:
- Title: The Godfather
- Release Date: March 24, 1972
- Award: 45th Academy Award for Best Picture
- Format: Fullscreen, Widescreen
- Genre: Drama
- Label: Paramount
- Rating: R
- Sound: DTS
- Make the following changes to the DVD titled “Zero Effect.” This DVD already exists in the database.
- New Label: Columbia TriStar
- New Genre: Comedy
- New Format: Fullscreen
- Delete the DVD titled “Major League 3:Back to the Minors” from the database. This DVD already exists in the database.
- Display the number of characters for the longest and shortest title in the database. Name columns
longest_title
andshortest_title
respectively. Use aggregate functions.
- Display all genres and number of DVDs belonging to each genre as
dvd_count
column. Show genre ID, genre name, and DVD count. Use an aggregate function.
Submission
When complete, you must upload the completed .sql
file to Blackboard. Go to Assignments -> Assignment 7: Full SQL Statements and upload the file.