Chinook sample database

The Chinook sample database for a digital media store can be used to explore and learn YugabyteDB.

About the Chinook database

The Chinook data model represents a digital media store, including tables for artists, albums, media tracks, invoices and customers.

  • Media-related data was created using real data from an Apple iTunes library.
  • Customer and employee information was created using fictitious names and addresses that can be located on Google maps, and other well formatted data (phone, fax, email, etc.)
  • Sales information was auto generated using random data for a four year period.

The Chinook sample database includes:

  • 11 tables
  • A variety of indexes, primary and foreign key constraints
  • Over 15,000 rows of data

For details, here’s the entity relationship diagram of the Chinook data model.

Chinook ER diagram

Before you begin

To install and use the Chinook sample database, you need to have installed and configured YugabyteDB. To get up and running quickly, see Quick Start.

Install the Chinook sample database

1. Download the SQL scripts

You can download the Chinook database that is compatible with YugabyteDB from the sample directory of the YugabyteDB GitHub repository. Download the following three files.

2. Open the YSQL shell

To open the YSQL shell, run the ysqlsh command from the YugabyteDB root directory.

  1. $ ./bin/ysqlsh
  1. ysqlsh (11.2)
  2. Type "help" for help.
  3. yugabyte=#

3. Create the Chinook database

To create the chinook database, run the following command.

  1. yugabyte=# CREATE DATABASE chinook;

Confirm that you have the chinook database by using the \l command to list the databases on your cluster.

  1. yugabyte=# \l

Connect to the chinook database.

  1. yugabyte=# \c chinook
  1. You are now connected to database "chinook" as user "yugabyte".
  2. chinook=#

4. Build the tables and objects

To build the tables and database objects, run the following \i command.

  1. chinook=# \i share/chinook_ddl.sql

You can verify that all 11 tables have been created by running the \d command.

  1. chinook=# \d

5. Load the sample data

To load the chinook database with sample data, you need to run the SQL scripts.

First, run the SQL script to load the genres, artists, and albums.

  1. chinook=# \i share/chinook_genres_artists_albums.sql

Next, run the SQL script to load the songs.

  1. chinook=# \i share/chinook_songs.sql

Now verify that you have data by running a simple SELECT statement to pull some data from the Track table.

  1. chinook=# SELECT "Name", "Composer" FROM "Track" LIMIT 10;
  1. Name | Composer
  2. ---------------------------------+------------------------------------------------------------
  3. Boa Noite |
  4. The Memory Remains | Hetfield, Ulrich
  5. Plush | R. DeLeo/Weiland
  6. The Trooper | Steve Harris
  7. Surprise! You're Dead! | Faith No More
  8. School | Kurt Cobain
  9. Sometimes I Feel Like Screaming | Ian Gillan, Roger Glover, Jon Lord, Steve Morse, Ian Paice
  10. Sad But True | Apocalyptica
  11. Tailgunner |
  12. Tempus Fugit | Miles Davis
  13. (10 rows)

Explore the Chinook sample database

That’s it! Using the command line or your favorite PostgreSQL development or administration tool, you are now ready to start exploring the chinook database and YugabyteDB features.