Northwind sample database

Download and install the PostgreSQL-compatible version of the Northwind dataset on the YugabyteDB distributed SQL database.

About the Northwind sample database

The Northwind database is a sample database that was originally created by Microsoft and used as the basis for their tutorials in a variety of database products for decades. The Northwind database contains the sales data for a fictitious company called “Northwind Traders,” which imports and exports specialty foods from around the world. The Northwind database is an excellent tutorial schema for a small-business ERP, with customers, orders, inventory, purchasing, suppliers, shipping, employees, and single-entry accounting. The Northwind database has since been ported to a variety of non-Microsoft databases, including PostgreSQL.

The Northwind dataset includes sample data for the following.

  • Suppliers: Suppliers and vendors of Northwind
  • Customers: Customers who buy products from Northwind
  • Employees: Employee details of Northwind traders
  • Products: Product information
  • Shippers: The details of the shippers who ship the products from the traders to the end-customers
  • Orders and Order_Details: Sales Order transactions taking place between the customers & the company

The Northwind sample database includes 14 tables and the table relationships are showcased in the following entity relationship diagram.

Northwind ER diagram

Install the Northwind sample database

Follow the steps here to download and install the Northwind sample database.

Before you begin

To use the Northwind sample database, you must have installed and configured YugabyteDB. To get up and running quickly, see Quick Start.

1. Download the SQL scripts

You can download the Northwind database files, which are compatible with YugabyteDB, from the sample directory of the YugabyteDB GitHub repository. Here are the two files you’ll need.

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 Northwind database

To create the Northwind database, run the following CREATE DATABASE statement.

  1. CREATE DATABASE northwind;

Confirm that you have the Northwind database by listing out the databases on your cluster.

  1. yugabyte=# \l

Northwind list of databases

Connect to the Northwind database.

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

4. Build the tables and objects

To build the tables and database objects, execute the northwind_ddl.sql SQL script.

  1. northwind=# \i share/northwind_ddl.sql

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

  1. northwind=# \d

Northwind list of relations

5. Load the sample data

To load the northwind database with sample data, run the \i command to execute commands in the northwind_data.sql file.

  1. northwind=# \i share/northwind_data.sql

To verify that you have some data to work with, you can run a simple SELECT statement to pull data from the customers table.

  1. northwind=# SELECT * FROM customers LIMIT 2;

Explore the Northwind database

That’s it! You are now ready to start exploring the Northwind database and YugabyteDB features using the command line or your favorite PostgreSQL tool.