Music sample database
Artists, albums and tracks with release years and durations.
3 tables · 68 rows · 16 KB
Tables
albums 18 rows
- album_id integer PK
- title text
- artist_id integer → artists
- release_year integer
| album_id | title | artist_id | release_year |
|---|---|---|---|
| 1 | Abbey Road | 1 | 1969 |
| 2 | Sgt. Pepper's Lonely Hearts Club Band | 1 | 1967 |
| 3 | The White Album | 1 | 1968 |
artists 10 rows
- artist_id integer PK
- name text
- genre text
| artist_id | name | genre |
|---|---|---|
| 1 | The Beatles | Rock |
| 2 | Pink Floyd | Progressive Rock |
| 3 | Michael Jackson | Pop |
tracks 40 rows
- track_id integer PK
- title text
- album_id integer → albums
- duration_seconds integer
| track_id | title | album_id | duration_seconds |
|---|---|---|---|
| 1 | Come Together | 1 | 259 |
| 2 | Something | 1 | 182 |
| 3 | Here Comes the Sun | 1 | 185 |
How the tables connect
- albums.artist_idartists.artist_id
- tracks.album_idalbums.album_id
Try a query
Use it on your computer
The SQLite file opens with the sqlite3 command-line tool or any SQLite app:
sqlite3 music.sqlite
.tables
For MySQL, PostgreSQL or SQL Server, run the SQL script instead. It is plain CREATE TABLE and INSERT statements
written for SQLite, so another database may need a small change.
8 practice questions on this database
- Easy Convert Seconds to Minutes Convert Track Duration to Minutes Free
- Easy Group Years by Decade Group Albums by Decade Free
- Easy Longest Item per Group Each Artist's Longest Song Free
- Easy UPDATE a Text Value Relabel the Genre Free
- Medium Rows Above Their Group Average Above-Average Track Length per Album Premium
- Medium Counts and Totals Across Joined Tables Most Prolific Artists Premium
- Medium Composite Index on Two Columns The Two-Column Index Premium
- Hard DELETE Using a Subquery Drop the Legacy Catalog Premium
Practice on your iPhone
Query Dojo for iPhone has 85 interview questions, timed mock interviews and a tile builder, so you can write queries without a keyboard.