DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • SQL Server to Postgres Database Migration
  • Advanced Maintenance of a Multi-Database Citus Cluster With Flyway
  • How to Build a Full-Stack App With Next.js, Prisma, Postgres, and Fastify
  • How to Store Text in PostgreSQL: Tips, Tricks, and Traps

Trending

  • How to Practice TDD With Kotlin
  • A Deep Dive Into Firmware Over the Air for IoT Devices
  • How to Configure and Customize the Go SDK for Azure Cosmos DB
  • Transforming AI-Driven Data Analytics with DeepSeek: A New Era of Intelligent Insights
  1. DZone
  2. Data Engineering
  3. Databases
  4. The Northwind PostgreSQL Sample Database Running on a Distributed SQL Database

The Northwind PostgreSQL Sample Database Running on a Distributed SQL Database

In this post, see how to download and install the PostgreSQL-compatible version of Northwind on the YugaByte DB distributed SQL database.

By 
Jimmy Guerrero user avatar
Jimmy Guerrero
·
Jul. 17, 19 · Opinion
Likes (5)
Comment
Save
Tweet
Share
22.6K Views

Join the DZone community and get the full member experience.

Join For Free

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.

In this post, we are going to walk you through how to download and install the PostgreSQL-compatible version of Northwind on the YugaByte DB distributed SQL database.

Download and Install YugaByte DB

For complete instructions on how to get up and running on a variety of platforms including prerequisites, check out our Quickstart Guide. In the following section, we’ll cover the basic steps for getting up and running in just a few minutes with a local 3 node cluster on your Mac.

Download and Extract

$ wget https://downloads.yugabyte.com/yugabyte-1.3.0.0-darwin.tar.gz
$ tar xvfz yugabyte-1.3.0.0-darwin.tar.gz && cd yugabyte-1.3.0.0/

Note: The above instructions are for version 1.3.0. To find the latest version of YugaByte DB, visit the quickstart page.

Configure Loopback Addresses

Add a few loopback IP addresses for the various YugaByte DB nodes to use.

sudo ifconfig lo0 alias 127.0.0.2
sudo ifconfig lo0 alias 127.0.0.3
sudo ifconfig lo0 alias 127.0.0.4
sudo ifconfig lo0 alias 127.0.0.5
sudo ifconfig lo0 alias 127.0.0.6
sudo ifconfig lo0 alias 127.0.0.7

Create a 3 Node Cluster

With the command below, you’ll create a 3 node cluster with a replication factor of 3.

$ ./bin/yb-ctl --rf 3 create

Check the Status of the Cluster

Now let’s take a look at the status of the cluster and all the nodes that comprise it.
$ ./bin/yb-ctl status

As you can see from the output, we have three nodes running locally with a replication factor of 3. This means that every piece of data is being replicated on all three nodes.

Enter the YSQL shell

Next, run the ysqlsh command to enter the PostgreSQL shell.

$ ./bin/ysqlsh --echo-queries
ysqlsh (11.2)
Type "help" for help.
postgres=#

What’s YSQL? It’s YugaByte DB’s PostgreSQL-compatible, distributed SQL API.

We are now ready to build the Northwind database.

Download and Install the Northwind Sample Database

Download Northwind

You can download the Northwind database that is compatible with YugaByte DB from our GitHub repo. Here are the two files you’ll need:

  • northwind_ddl.sql, which creates tables and other database objects
  • northwind_data.sql, which loads the sample data into Northwind

Create the Northwind Database

CREATE DATABASE northwind;

Let’s confirm we have the Northwind database by listing out the databases on our cluster.

postgres=# \l

Switch to the Northwind database.

postgres=# \c northwind
You are now connected to database "northwind" as user "postgres".
northwind=#

Build the Northwind Tables and Objects

northwind=# \i /Users/yugabyte/northwind_ddl.sql

We can verify that all 14 of our tables have been created by executing:

northwind=# \d


Load Sample Data into Northwind

Next, let’s load our database with sample data.

northwind=# \i /Users/yugabyte/northwind_data.sql

Let’s do a simple SELECT to pull data from the customers table to verify we now have some data to play with.

northwind=# SELECT * FROM customers LIMIT 2;

Explore Northwind

The dataset consists of 14 tables, and the table relationships are showcased in the entity relationship diagram below:

The dataset contains 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 and the company

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

Database PostgreSQL sql cluster

Opinions expressed by DZone contributors are their own.

Related

  • SQL Server to Postgres Database Migration
  • Advanced Maintenance of a Multi-Database Citus Cluster With Flyway
  • How to Build a Full-Stack App With Next.js, Prisma, Postgres, and Fastify
  • How to Store Text in PostgreSQL: Tips, Tricks, and Traps

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!